urbanvoice Posted February 4, 2009 Share Posted February 4, 2009 Hello! I have a pain in the arse client that wants a default image to appear when no image from the thumbnail gallery. Below is the code.. I would like to have a default image appear on the main page.. once a thumbnail is selected then it exchanges the image with the selection. Thanks in advance.. <?php require_once("config.php"); $select = "SELECT * FROM gallery ORDER BY category ASC"; $sql = mysql_query($select); $num = mysql_num_rows($sql); $lastCat = ""; for($a = 0; $a < $num; $a++) { $currentCat = mysql_result($sql, $a, 'category'); if($lastCat != "") { if($currentCat == $lastCat){ $printGal .= ' <div style="width: 50px; height: 50px; margin: 5px; position: relative; float: left; border: 1px solid #000; background-image: url(\'gallery/'. mysql_result($sql, $a, 'img_name') .'\'); background-repeat: no-repeat; background-position: center top;" onClick="changeImg(\''.mysql_result($sql, $a, 'img_name').'\');"> </div>'; } else { $printGal .= ' </td> </tr> <tr> <td width="262" height="3" style="background-color: #FFFFFF;"> </td> </tr> <tr> <td width="262" height="26" style="background-color: #c1c38b;"> </td> </tr> <tr> <td width="262" height="3" style="background-color: #FFFFFF;"> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" width="262"> <tr> <td width="262" height="77" style="background-color: #e3e9f5;"> <div style="margin: 5px; margin-bottom: 0px; font-family: Verdana; font-size: 12px; color: #b95915; font-weight: bold;"> '. stripslashes(mysql_result($sql, $a, 'category')) .' </div> <div style="width: 50px; height: 50px; margin: 5px; position: relative; float: left; border: 1px solid #000; background-image: url(\'gallery/'. str_replace(".", "_thumb.", mysql_result($sql, $a, 'img_name')) .'\'); background-repeat: no-repeat; background-position: center top;" onClick="changeImg(\''.mysql_result($sql, $a, 'img_name').'\');"> </div>'; } } else { $printGal .= ' <table border="0" cellpadding="0" cellspacing="0" width="262"> <tr> <td width="262" height="77" style="background-color: #e3e9f5;"> <div style="margin: 5px; margin-bottom: 0px; font-family: Verdana; font-size: 12px; color: #b95915; font-weight: bold;"> '. stripslashes(mysql_result($sql, $a, 'category')) .' </div> <div style="width: 50px; height: 50px; margin: 5px; position: relative; float: left; border: 1px solid #000; background-image: url(\'gallery/'. str_replace(".", "_thumb.", mysql_result($sql, $a, 'img_name')) .'\'); background-repeat: no-repeat; background-position: center top;" onClick="changeImg(\''.mysql_result($sql, $a, 'img_name').'\');"> </div>'; } $lastCat = mysql_result($sql, $a, 'category'); if($a + 1 == $num) { $printGal .= ' </td> </tr> <tr> <td width="262" height="3" style="background-color: #FFFFFF;"> </td> </tr> <tr> <td width="262" height="26" style="background-color: #c1c38b;"> </td> </tr> <tr> <td width="262" height="3" style="background-color: #FFFFFF;"> </td> </tr> </table>'; } } ?> Link to comment https://forums.phpfreaks.com/topic/143792-display-default-image-when-no-image-is-selected/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.