hi i'm trying to create a search function for my website and I keep getting this error
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/a7526299/public_html/SearchResult.php on line 158
<form action='SearchResult.php' method= 'get'>
<input type='test' name='k' size='50' value='<?php echo $_GET['k']; ?>' />
<input type='submit' value='search' />
</form>
<br />
<br />
Search Results
<br />
<br />
<br />
<br />
<?php
$k = $_GET['k'];
$terms = explode (" ", $k);
$query = "SELECT * FROM Products WHERE ";
foreach ($terms as $each) {
$i++;
if ($i == 1)
$query .="keywords LIKE '%each%' ";
else
$query .="OR keywords LIKE '%each%' ";
}
// connect
mysql_connect ("", "", ");
mysql_select_db("Products");
$query = mysql_query ($query);
$numrows = mysql_num_rows($query);
if ($numbers > 0) {
while ($row = mysql_fetch_assoc($query))
{
$id= $row['id'];
$id= $row['Brand'];
$id= $row['Description'];
$id= $row['Category'];
$id= $row['Price'];
$id= $row['Image'];
echo "$id, $Brand $Description, $Category, $Price, $Image";
}
}
else
echo "No results found for $k";
// disconnect
mysql_close();
?>