Code:
<?php
$query1="SELECT `item`,`picture`,`code` FROM `Gallery` where `active` ='1' order by `item` DESC LIMIT 5";
$result1 = mysql_query($query1);
$num_rows = mysql_num_rows($result1);
for($i = 0; $i < $num_rows; $i++) {
$row = mysql_fetch_array($result1);
$product=mysql_result($result1,$i,"item");
$photoid=mysql_result($result1,$i,"picture");
$ext=mysql_result($result1,$i,"code");
if (file_exists('$siteurl/photo/$photoid.$ext')) {
echo "Product: <img src='$siteurl/photo/$photoid.$ext'><a href='$siteurl/$product.html'><font color=Red>$product</font></a><br />";
} else {
echo "Product: <img src='$siteurl/nophoto/emptypic.jpg'><a href='$siteurl/$product.html'><font color=Red>$product</font></a><br />";
}
}
?>