Path to display image

5 posts by 3 authors in: Forums > CMS Builder
Last Post: May 4, 2010   (RSS)

By paulmac - May 4, 2010

Hi

I'm trying to build up a table that will display an image and a project description for that image. Displaying the project description is fine, but I can't work out how to display the path to the image. The code is:

<table width="100%" border="1" cellspacing="0" cellpadding="4">


<?php foreach ($client_testimonialsRecords as $record): ?>

<?php if ( $record['home_page'] == 1 ) {
echo "<tr>";
echo "<td>";
echo "<img src=\"$thumbUrlPath\" alt=\"image name\" />";
echo "<td>";
echo $record['project_description'];
echo "</td>";
echo "</td>";
echo "</tr>";
} ?>

<?php endforeach ?>
</table>

Appreciate any help.

Thanks

Re: [paulmac] Path to display image

By gkornbluth - May 4, 2010

Hi Paulmac,

If I understand you correctly, I think you need think you'll need a foreach loop around your image call as well to pull the images from your record.

<?php foreach ($record['image'] as $upload): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" />
<?php endforeach ?>


Hope that works for you

Best,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [paulmac] Path to display image

By paulmac - May 4, 2010

Hi Jerry

That makes sense all right, my only problem is my php skills aren't that strong. Could you advise on the correct syntax to get this working.

Thanks

Re: [paulmac] Path to display image

By Jason - May 4, 2010

Hi,

Jerry's right, you need to go through each of image for each record (in case there is more than one).

So if you wanted to output a table with your images, you may want to use something like this:

<table width="100%" border="1" cellspacing="0" cellpadding="4">
<?php foreach ($client_testimonialsRecords as $record): ?>
<?php if ( $record['home_page'] == 1 ): ?>
<tr>
<?php foreach ($record['image'] as $upload): ?>
<td><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /> </td>
<?php endforeach ?>
<td><?php echo $record['project_description']; ?></td>
</tr>
<?php endif ?>
<?php endforeach ?>

</table>


You may want to rearrange your <td></td> tags depending on how you want it to be formatted. Give this a try and let me know how it works for you.

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/