i need help for my php script:
This is my index.php:
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
$db_hostname = '127.0.0.1';
$db_username = 'root';
$db_password = 'password';
$db_database = 'mydatabase';
$connect = mysqli_connect("$db_hostname","$db_username","$db_password");
if (!$connect){
die('Could not connect: ' . mysqli_error());
}
mysqli_select_db($connect, $db_database) or die ("could not find db");
$output ='';
if (isset ($_POST['search'])){
$search = $_POST['search'];
}
$query = mysqli_query($connect, "SELECT * FROM user WHERE email LIKE '%$searchq%'") or die("could not search");
$count = mysqli_num_rows($query);
if($count == 0){
$output = 'There was no search results !';
}
else{
while($row = mysqli_fetch_array($query)){
$fname = $row['email'];
$output .='<div> '.$fname.'</div>';}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8" />
<title>Lookup</title>
</head>
<body>
<form action="index.php" method="post">
<input type="text" placeholder="search" name="search">
<input type="submit" value=">>"/>
</form>
<?php
print("$output");
?>
</body>
</html>
So the script works and its return me email from email column where my string is found.
But i have another question, i have another column beside my email column named location, and every email correspond to a location value. So i want to see 2 columns on my OUTPUT.
This is example an of my columns:
| email | location |
| [email protected] | Chicago |
| [email protected] | Mexico |
- So this is what result i actually see on my index.php:
[email protected] [email protected] [email protected] [email protected]
- And this is what i want to see:
[email protected] Tokyo [email protected] London [email protected] Paris [email protected] New-York
Thanks for your help.
$row['location']