I'm using PHP to search my database and present information on a separate search results page. Please see the php script below. With my current script I can only showcase one result. How can I showcase multiple results? Also, how can I add a CSS class to a part of my PHP code?
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$k = $_GET['k'];
$terms = explode(" ", $k);
$query = "SELECT * FROM search WHERE ";
$i = 0;
foreach ($terms as $each){
$i++;
if ($i == 1)
{
$query .= "keywords LIKE '$each%' ";
}
else
{
$query .= "OR keywords LIKE '$each%' ";
}
}
// connect
mysql_connect("host","user","pass");
mysql_select_db("DB1");
$query = mysql_query($query);
$numrows = mysql_num_rows($query);
if ($numrows > 0){
while ($row = mysql_fetch_assoc($query)){
$id = $row['id'];
$title = $row['title'];
$description = $row['description'];
$keywords = $row['keywords'];
$link = $row['link'];
echo "<h1><a href='$link'>$title</a></h1>
<h2>$link</h2><br /><br />
$description<br /><br />
$keywords<br /><br />";
}
}
else
{
echo "No Search Results Were Found for \"<b>$k<b>\"";
}
// disconnect
mysql_close();
?>
Please help! Thanks in advance.