Need Help with If Exists for Uploads

3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 27, 2008   (RSS)

By pcolvin - October 26, 2008

I need to test if and upload or uploads exist for a records being displayed in a list. The uploads are images and I need to display an icon to show if any photos have been uploaded to that record.

Below is the code I have to display the list in a table.

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

<table border="0" cellpadding="2" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="100%" colspan="2"><h2><a href="<?php echo $record['_link'] ?>"><?php echo $record['nature'] ?> - <?php echo $record['municipality'] ?></a></h2>
</td>
<tr>
<td width="6%" align="right">Date:</td>
<td width="94%"><?php echo date("D, M d, Y H:i", strtotime($record['date'])) ?></td>
<tr>
<td width="6%" align="right">Address:</td>
<td width="94%"><?php echo $record['location'] ?></td>
</tr>
<tr>
<td width="6%" align="right">Details:</td>
<td width="94%"><?php echo $record['content'] ?></td>
</tr>

</table>
<br/>
<hr/>


<?php if (!$incidents_newsRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
<?php endforeach ?>

I have tried some code within the foreach loop but of course that returns a positive in the if exists statement for all photos associated with the record. All I need to know is if one or more photos (uploads) are associated with that record in the table. I'm pretty sure the test will need to be done within the foreach loop so each record that does have uploads can display the icon.

I'm sure there is an easy fix for this, I just don't have enough PHP experience to figure this one out yet.

Any help will be appreciated.

Thank you...

Re: [Dave] Need Help with If Exists for Uploads

By pcolvin - October 27, 2008

Works perfectly. Thank you...