Jump to content

Help with image display


vmicchia

Recommended Posts

Hey there, my problem is that I am trying to pull three images from a database and then displaying them with a large image above them. I want to then be able to click the smaller ones and then they become the larger one(kind of like on amazon). I am having 2 major problems with it at this point. the first is my while statement is only pulling 2 of the three images from the database, and secondly my image replacement javascript replaces with the smaller image. With the javascript it dosen't have to be done that way or in javascript so a link or suggestions on how to do that better would be great.

 

So here's my code:

<?php
include('../../php/includes/openDbConn.php');
$sku = 'c-111111';
$getImages = "SELECT * FROM Images WHERE SKU = '".$sku."'";
$resultGetImages = mysql_query($getImages);
$records = mysql_fetch_assoc($resultGetImages);
?>
   <img src="../../<?php echo $records['Path'] ?>" id="placeholder" alt="<?php echo $record['Description']; ?>" height="<?php echo $record['Width']; ?>" />
    <div id="thumbImages">
      <?php
while($records = mysql_fetch_assoc($resultGetImages)){
    echo "<a onclick=\"document.getElementById('placeholder').src='../../".$records['ThumbPath']."'\" target=\"_blank\"><img src=\"../../".$records['ThumbPath']."\" alt=\"".$records['Description']."\" height=\"".$records['ThumbWidth']."\" /></a>\n";
}
?>

 

and a bit on the table with the images. It stores the sku and the Path of a thumbnail, regular and large sized image. All help is much appreciated.

Link to comment
https://forums.phpfreaks.com/topic/216902-help-with-image-display/
Share on other sites

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.