Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Image default

Status
Not open for further replies.

chotch

Technical User
Jan 30, 2007
8
GB
MY CODE IS AT THE BOTTOM OF THE PAGE AND I AM USING phpMyAdmin 2.5.2 MySQL 3.23.56 running

Thank you all in advance,
I need to show a default image in the event that a dynamic image does not exist, or blank space would be great. Can anyone help.

Also could you let me know how to swap the main image from the thumbnails (click)and rotate the images round please. Simple gallery I guess but dynamic.

Kind Regards

JC


require 'listing.inc';

if (array_key_exists("propID", $_GET))
$propertyID = $_GET["propID"];
else
die("Sorry, cannot locate the details for that property");

$query = "SELECT Price, PropertyID, Area, MainDescription, Parking, cFacility1, cFacility2, cFacility3, cFacility4, ";
$query = $query . "cFacility5, cFacility6, cFacility9, PropertyName FROM listings WHERE PropertyID = '{$propertyID}';";

// Connect to the server
if (!($connection = @ mysql_connect($hostName, $userName, $password)))
die("Cannot connect to server {$hostName}");

// print '<div class="debug">Opening database</div>' . "\n";

// Select the database
if (!(mysql_select_db($databaseName, $connection)))
showDbError();

// print '<div class="debug">Issuing query</div>' . "\n";

if (!($result = @ mysql_query($query, $connection)))
showDbError();

if (!($record = @ mysql_fetch_array($result)))
die("Sorry, cannot locate the details for that property");

$imageFile = "photos/pBRANCH_{$record["PropertyID"]}.jpg";
$imageFile2 = "photos/bBRANCH_{$record["PropertyID"]}.jpg";


print " <tr>\n";
print ' <td height="277" width="411">' . "\n";
print ' <div align="center">' . "\n";
print " <img src=\"{$imageFile}\"";
print ' border="0" height="225" width="340" alt="Property photo" />' . "\n";
print " <img src=\"{$imageFile}\"";
print ' border="0" height="60" width="80" alt="Property photo" />' . "\n";
print " <img src=\"{$imageFile2}\"";
print ' border="0" height="60" width="80" alt="" />' . "\n";
print " <img src=\"{$imageFile}\"";
print ' border="0" height="60" width="80" alt="Property photo" />' . "\n";
print " <img src=\"{$imageFile}\"";
print ' border="0" height="60" width="80" alt="Property photo" />' . "\n";
print " </div> </td>\n";
print ' <td valign="top" width="389"><p class="style5"><br>' . "\n";
print ' <span class="style6"><span class="style8">Property</span><span class="style7"><br>Details</span></span>' . "\n";
print ' <br><br><strong><br>Area:</strong>' . "\n";
print "{$record["PropertyName"]}<br><strong>Price:</strong><span class=\"style24\"> &pound;{$record["Price"]} PCM</span>\n";
print " <br><br></p></td></tr>\n";
print ' <tr><td><table align="center" border="0" cellpadding="0" cellspacing="0" height="181" width="387">' . "\n";
print " <tr>\n";
print ' <td bgcolor="#547cad" width="44">&nbsp;</td>' . "\n";
print ' <td bordercolor="#FFFFFF" bgcolor="#547cad" width="153"><span class="style17">&#8226; ';
print "{$record["cFacility1"]}</span></td>\n";
print ' <td bgcolor="#547cad" width="190"><span class="style17">&#8226; ';
print "{$record["cFacility2"]}</span></td>\n";
print " </tr>\n";
print " <tr>\n";
print ' <td bgcolor="#547cad" width="44">&nbsp;</td>' . "\n";
print ' <td bordercolor="#FFFFFF" bgcolor="#547cad" width="153"><span class="style17">&#8226; ';
print "{$record["cFacility3"]}</span></td>\n";
print ' <td bgcolor="#547cad" width="190"><span class="style17">&#8226; ';
print "{$record["cFacility4"]}</span></td>\n";
print " </tr>\n";
print " <tr>\n";
print ' <td bgcolor="#547cad" width="44">&nbsp;</td>' . "\n";
print ' <td bordercolor="#FFFFFF" bgcolor="#547cad" width="153"><span class="style17">&#8226; ';
print "{$record["cFacility5"]}</span></td>\n";
print ' <td bgcolor="#547cad" width="190"><span class="style17">&#8226; ';
print "{$record["cFacility6"]}</span></td>\n";
print " </tr>\n";
print " <tr>\n";
print ' <td bgcolor="#547cad" width="44">&nbsp;</td>' . "\n";
print ' <td bordercolor="#FFFFFF" bgcolor="#547cad" width="153"><span class="style17">&#8226; ';
print "{$record["cFacility9"]}</span></td>\n";
print ' <td bgcolor="#547cad" width="190"><span class="style17">&#8226; PARKING ';
print "{$record["Parking"]}</span></td>\n";
print " </tr>\n";
print " </table></td>\n";
print ' <td><p class="style5" align="justify"><strong>Main Description: </strong><br><br>' . "\n";
print "{$record["MainDescription"]}\n";
print ' </p><p class="style9">&nbsp;&nbsp;&nbsp;<a href="mailto:?subject=';
print "{$record["PropertyName"]}";
print '">REGISTER INTEREST </a></p></td>' . "\n";
print " </tr>\n";
?>
 
If you don't get an answer, there is a PHP forum here (434) that might offer you more help.

 
forum434 is the place to ask, but here's a funciton that will get you on your way.

Note: This is adapted from something I have that operates with data being pulled from a database table.

Code:
function product_image($filename){
	
	if(!file_exists($_SERVER['DOCUMENT_ROOT']."/images/{$filename}") || trim($filename==""))
	{
		// return path to awaiting image graphic
		$imagepath = "/images/products/awaitingImage.gif";
	} else {
		// return path to image
		$imagepath = "/images/products/$filename";
	}
	
	return $imagepath;
}


When you write your HTML image tag do it like this

Code:
<img src="<?=product_image('myimage.jpg');?>" alt="blah" />

I think that will work

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top