I'm having some trouble trying to display a message if my query returns no records, pretty sure its the if($result == "") part just not sure what it should be.
Thanks in advance
Code:
$query = "SELECT * FROM products WHERE `sub_category` = '$pg'";
$result = mysql_query($query);
if($result == "")
{
echo "This category is empty";
}
else
{
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "<div class=\"productbox\">\n";
echo "<h2>{$row['product_name']}</h2>\n";
echo "<p>{$row['product_description']}... <a href=\"moreinfo.htm\">(more info)</a></p><br>\n";
echo "<div class=\"imagebox\"><img src=\"images/products/{$row['image_name']}\"></div>\n";
echo "<span class=\"price\">Price: £{$row['product_price']}<br/><a href=\"buy.htm\">Buy Now</a></span>\n";
echo "</div>\n\n";
}
}
Thanks in advance