edhan
12-17-2008, 02:50 AM
Hi
I am wondering if anyone knows how I can display a default photo if the picture is not found in the database while extracting. The default photo is located in a different folder.
Example: domain.com/images/default.jpg
Here is my 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");
echo "Product: <img src='$siteurl/photo/$photoid.$ext'><a href='$siteurl/$product.html'><font color=Red>$product</font></a><br />
";
}
?>
Currently if the picture exists, it will display them but when the picture is non existence, it will not display (show as missing image). So, instead of not displaying, I am thinking of showing the default photo instead.
How can I do that? Any help is greatly appreciated.
I am wondering if anyone knows how I can display a default photo if the picture is not found in the database while extracting. The default photo is located in a different folder.
Example: domain.com/images/default.jpg
Here is my 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");
echo "Product: <img src='$siteurl/photo/$photoid.$ext'><a href='$siteurl/$product.html'><font color=Red>$product</font></a><br />
";
}
?>
Currently if the picture exists, it will display them but when the picture is non existence, it will not display (show as missing image). So, instead of not displaying, I am thinking of showing the default photo instead.
How can I do that? Any help is greatly appreciated.