Multi Record show 1 image
5 posts by 2 authors in: Forums > CMS Builder
Last Post: February 10, 2009 (RSS)
By s2smedia - February 9, 2009
I have a 2 of the same multi record codes on 1 page.
Section 1: the one area i want listing the events.. (works fine)
Section 2: the other area i just want randomly displaying 1 of the records image uploaded..
heres my code...but this is showing all record images:
Section 1: (Works Fine)
<?php foreach ($eventsRecords as $record): ?>
<tr>
<td width="5" align="left" valign="middle"><img src="images/global/arrow.gif" alt=">" width="5" height="6" /></td>
<td width="32" align="left" valign="middle" style="padding:0px 0px 0px 8px"><span class="listingdate"><?php echo date("n / d", strtotime($record['date_time'])) ?></span></td>
<td width="150" align="left" valign="middle" style="padding:0px 0px 0px 8px" class="listing1"><?php echo $record['title'] ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php if (!$eventsRecords): ?>
<?php endif ?>
Section 2: ( i only want 1 image to show, preferably randomly)
<?php foreach ($eventsRecords as $record): ?>
<?php foreach ($record['image'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>
<?php else: ?>
<?php endif ?>
<?php endforeach ?>
<?php endforeach; ?>
<?php if (!$eventsRecords): ?>
<?php endif ?>
Section 1: the one area i want listing the events.. (works fine)
Section 2: the other area i just want randomly displaying 1 of the records image uploaded..
heres my code...but this is showing all record images:
Section 1: (Works Fine)
<?php foreach ($eventsRecords as $record): ?>
<tr>
<td width="5" align="left" valign="middle"><img src="images/global/arrow.gif" alt=">" width="5" height="6" /></td>
<td width="32" align="left" valign="middle" style="padding:0px 0px 0px 8px"><span class="listingdate"><?php echo date("n / d", strtotime($record['date_time'])) ?></span></td>
<td width="150" align="left" valign="middle" style="padding:0px 0px 0px 8px" class="listing1"><?php echo $record['title'] ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php if (!$eventsRecords): ?>
<?php endif ?>
Section 2: ( i only want 1 image to show, preferably randomly)
<?php foreach ($eventsRecords as $record): ?>
<?php foreach ($record['image'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>
<?php else: ?>
<?php endif ?>
<?php endforeach ?>
<?php endforeach; ?>
<?php if (!$eventsRecords): ?>
<?php endif ?>
Re: [s2smedia] Multi Record show 1 image
By Dave - February 9, 2009
Hi s2smedia,
Try this:
Let me know if that works for you.
Try this:
<?php foreach ($eventsRecords as $record): ?>
<?php shuffle($record['image']); ?>
<?php foreach ($record['image'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>"
width="<?php echo $upload['width'] ?>"
height="<?php echo $upload['height'] ?>"
alt="" /><br/>
<?php break; ?>
<?php endforeach ?>
<?php endforeach; ?>
Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com
interactivetools.com
Re: [Dave] Multi Record show 1 image
Its still showing all 3 images.
Re: [s2smedia] Multi Record show 1 image
By Dave - February 10, 2009
Try this:
That will show one random image from one random record in the list.
Hope that helps!
<?php shuffle($eventsRecords); ?>
<?php foreach ($eventsRecords as $record): ?>
<?php shuffle($record['image']); ?>
<?php foreach ($record['image'] as $upload): ?>
<img src="<?php echo $upload['urlPath'] ?>"
width="<?php echo $upload['width'] ?>"
height="<?php echo $upload['height'] ?>"
alt="" /><br/>
<?php break; ?>
<?php endforeach ?>
<?php break; ?>
<?php endforeach; ?>
That will show one random image from one random record in the list.
Hope that helps!
Dave Edis - Senior Developer
interactivetools.com
interactivetools.com