I'm working with a shopping cart script for a bike shop's website I'm doing and am currently having trouble with the "Sale Items" part. If there are items for sell it works fine and displays them on the home page along with the link to them in the shopping cart.
But if there are no items for sale it leaves it blank. I tried to use the if else statement but all I got was errors. All I'm looking to do is have it so if there are no items on sale to have it shoot back "No Sale Items." to the browser. Well simple enough here's the code...
// list top 5 sale items
$sale_prod = "SELECT *
FROM ".$prefix."store_inventory where sale_price > 0 order by rand() desc LIMIT 10";
$sale_prod_result = mysql_query($sale_prod);
$no = 0;
while($row = mysql_fetch_array($sale_prod_result)){
$title=$row["title"];
$product=$row["product"];
// format title so not too long
$title=stripslashes($title);
$title=substr($title,0,13);
$image = $row["image"];
$no = $no + 1;
if (!file_exists("$site_dir/images/" . "thumb_$image")){
$thumb=new thumbnail("$site_dir/images/$image");
$thumb->size_auto(100);
$thumb->jpeg_quality(100);
$thumb->save("$site_dir/images/thumb_$image");}
echo"<a href=\"storefront/view_product.php?product=$product\" target=\"_self\"><img src=\"storefront/images/thumb_$image\"border=\"0\"><br>$title";
// display .. if title is longer that 13 chars
if(strlen($title)>=13)
{echo"..";}
echo"</a><br>";
}
If someone could please help me out I would really appreciate it. Thanks in advance!