Hello,
I have a search on my site. It searches products in a catalog database. If you hit submit without anything in the search filed it comes back with all products in my catalog. Is there a way to stop this with a IF statement or something else. Any help will be great. Thanks.
Here is my search code.
<?php
$sql="SELECT * FROM products WHERE name LIKE '%$searchstring%' ";
$search_result = mysql_query ($sql) or die('Error executing sql: '.$sql.'<br />MySQL Reported:'.mysql_error());
while ($row = mysql_fetch_array ($search_result))
{
echo "<a href=\"" . $row["url"] . "\"><img src=\"" . $row["imagefile"] . "\" border=0 alt=\"" . $row["name"] . "\"></a><BR>";
echo "<b>" . $row["name"] . "</b><br>";
echo $row["description"] . "<br>";
echo "<b>Price: $</b>";
echo "<b>" . $row["price"] . "</b><br><hr /><br>";
}
?>
Jeremy