Show one image only from a list of image uploads

2 posts by 2 authors in: Forums > CMS Builder
Last Post: January 26, 2011   (RSS)

Re: [Mercer Design] Show one image only from a list of image uploads

By Jason - January 26, 2011

Hi,

Each image has a unique num. So when you're outputting your list of images, you can make each one a link like this

EXAMPLE:
<?php foreach($record['images'] as $image):?>
<a href="detailPage.php?imgNum=<?php echo $image['num'];?>">
<img src="<?php echo $image['thumbUrlPath'];?>" width="<?php echo $image['thumbWidth'];?>" height="<?php echo $image['thumbHeight'];?>" />
</a>
<?php endforeach ?>


So in this we're passing the number of the image to the detailPage in a variable called imgNum.

On the detail page, when looping through our images, we can make sure we're only outputting that single image.

EXAMPLE:
<?php foreach $record['images'] as $image):?>
<?php if($image['num']!=@$_REQUEST['imgNum']){ continue;} ?>

<img src="<?php echo $image['urlPath'];?>" height="<?php echo $image['height'];?>" width="<?php echo $image['width'];?>" />
<?php endforeach ?>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/