Here is some php code I made(comes with database). My problem is when I search it shows me only 1 result from the table even though they are more. for example the table has names(david star and david plumber) if I search for david it displays only one of both instead of both. Would really appreciate any possible help. Thanks.
<?php
//load database connection
$host = "localhost";
$user = "root";
$password = "";
$database_name = "autocomplete";
$pdo = new PDO("mysql:host=$host;dbname=$database_name", $user,
$password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
));
// OR author LIKE '%$search%' LIMIT 0 , 10
$search=$_POST['studentnum'];
$query = $pdo->prepare("select *
from search, search_and_highlight
where Name LIKE '%$search%'");
$query->bindValue(1, "%$search%", PDO::PARAM_STR);
$query->execute();
// Display search result
if (empty($search)) {
echo "<p>You forgot to enter a search term!!!";
} else
if ( $results = $query->fetch()) {
echo ' <div class="tm-sidebar-pad-2">
<a href="#" class="media tm-media tm-recommended-item">
<img src="img/img-01.jpg" alt="Image">
<div class="media-body tm-media-body tm-bg-gray">
<h4 class="text-uppercase tm-font-semibold tm-sidebar-item-title">'.$results['Name'].'</h4>
<h4 class="text-uppercase tm-font-semibold tm-sidebar-item-title">
echo </h4>
<h4 class="text-uppercase tm-font-semibold tm-sidebar-item-title">Kategorie</h4>
<h4 class="text-uppercase tm-font-semibold tm-sidebar-item-title">. </h4>
<h4 class="text-uppercase tm-font-semibold tm-sidebar-item-title">. </h4>
<h4 class="text-uppercase tm-font-semibold tm-sidebar-item-title">Kategorie</h4>
<h4 class="text-uppercase tm-font-semibold tm-sidebar-item-title">. </h4>
<h4 class="text-uppercase tm-font-semibold tm-sidebar-item-title">Preis</h4>
</div>
</a>
</div>';
} else {
echo 'Nothing found';
}
?>