hi there. Ive got a search engine that doesn’t work. So far it’s ment to say if there’s any resilts found. However when i’m typing in the keywords it’s saying no results found. could anyone please take a look??
<?php
//get data
$button = $_GET['submit'];
$search = $_GET['search'];
if (!$button)
echo "You didn't submit a keyword.";
else
{
if (strlen ($search)<=1)
echo "Search term too short.";
else
{
echo "You searched for <b>$search</b><hr size='1'>";
//connect to database
include('config.php');
mysql_select_db("student_bay_co_", $connection);
//explode our search term
$search_exploded = explode(" ",$search);
foreach($search_exploded as $search_each)
{
//construct query
$x++;
if ($x==1)
$construct .= "keywords LIKE '%$search_each%'";
else
$construct .= " OR keywords LIKE '%$search_each%'";
}
//echo out construct
$construct = "SELCECT * FROM products1 WHERE $construct";
$run = mysql_query($construct);
$foundnum = mysql_num_rows($run) ;
if ($foundnum==0)
echo "No results found.";
else
{
echo "echo $foundnum results found!<p>";
}
}
}
?>