I've made a search function in PHP which pretty much gives me information from my database when I search for the same word. So if I type the word 'mouse' in my search bar it gives me all the results with the word 'mouse' from my database. The problem is... it doesn't give me all the results with the word 'mouse'. It only gives me 1 result. Here is my code:
if(isset($_POST["searchbutton"])){
$query = $_POST['search'];
mysql_connect("localhost", "root", "") or die("Error connecting to database: ".mysql_error());
mysql_select_db("reserveringssysteem") or die(mysql_error());
$raw_results = mysql_query("SELECT * FROM users
WHERE (`Voornaam` LIKE '%".$query."%') OR (`Achternaam` LIKE '%".$query."%') OR ('Email' LIKE '%".$query."%')") or die(mysql_error());
if(mysql_num_rows($raw_results) > 0){
while($results = mysql_fetch_array($raw_results)){
$message4 = "<p><b>".$results['Voornaam']." ".$results['Achternaam']."</b><br>".$results['Email']."</p>";
}
}
else{
$message4 = "No results";
}
}
And this is the code that's in my HTML:
<?php if($message4) { ?>
<p><?= $message4; ?></p>
<?php } ?>
Anyone know what I did wrong?
".$results['Voornaam']." ".$results['Achternaam']."
"; }` – Mark Baker Jan 26 '15 at 15:52".$results['Email']."