Hi all,
I have just made a search bar for a site but I am having trouble trying to return the number of results that are found.
E.g. I want it to print "Your search terms returned 'xx' results" after each search.
This is my code:
<?php
include ('db.php');
if (isset($_POST['search'])) {
$searchterm = $_POST['searchterm'];
$searchcat = $_POST['searchcat'];
$searchterm = trim($searchterm);
if (!$searchterm && !$searchcat) {
echo 'no search terms entered';
exit;
}
$getresults = mysql_query("SELECT * from auctions WHERE a_title LIKE '%".$searchterm."%' OR category_id = '$catid'");
$i=0;
while ($i < 10 and $matches = mysql_fetch_assoc($getresults)) {
//return number of matches &
//display results here...
}
?>
Thanks, Nonshatter