Jump to content

Display Default Image when no Image is Selected


urbanvoice

Recommended Posts

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>';
}
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.