Making the table add columns automatically

2 posts by 1 authors in: Forums > CMS Builder
Last Post: May 14, 2014   (RSS)

By dccreatives - May 14, 2014

I want my records to show in one table with 6 columns. I only want them to show if there is a record there: Right now this list makes it stack on on top of the other: See this page: http://www.axislighting.com/CMS/itemsDetail_slimLite.php?258 Bottom of Page where there are downloads.

<table>
<tr>


<?php foreach ($downloadsRecord['icon_brochure'] as $index => $upload): ?>
<td><a href="/CMS/downloadsDetail-pop-b.php?<?php echo $itemsRecord['download_id'] ?>" target="_blank" class="style10" rel="gb_page_center[700, 480]"> <img src="<?php echo $upload['urlPath'] ?>" alt="" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" border="0" align="center" /></a></td>
</tr>

<?php if (@$downloadsRecord['brochure']): ?>
<tr>
<td><center>
<a href="/CMS/downloadsDetail-pop-b.php?<?php echo $itemsRecord['download_id'] ?>" target="_blank" class="style10" rel="gb_page_center[700, 480]">Brochure</a></center>
<?php endif ?> </td><?php endforeach ?></tr>


<?php foreach ($downloadsRecord['icon_spec_sh'] as $index => $upload): ?>
<td><a href="/CMS/downloadsDetail-pop-ss.php?<?php echo $itemsRecord['download_id'] ?>" target="_blank" class="style10" rel="gb_page_center[700, 480]"> <img src="<?php echo $upload['urlPath'] ?>" alt="" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" border="0" align="center" /></a></td>
</tr>

<?php if (@$downloadsRecord['specification_sheets']): ?>
<tr>
<td><center>
<a href="/CMS/downloadsDetail-pop-ss.php?<?php echo $itemsRecord['download_id'] ?>" target="_blank" class="style10" rel="gb_page_center[700, 480]">Specification Sheets</a></center>
<?php endif ?></td> <?php endforeach ?></tr>


</table>

I am not sure how to make the table loop, because each record is a separate field. I have brochures, specification sheets, etc. I want if there is an upload it should add it to the columns in the table. In addition, if there is an upload I need it to show the icon as well, which is another field in the record.

How can I do this: 

I have some things in tables, but they work nicely because they are multiple uploads of one field. For example:

This page the mounting images loop but they are all part of the mounting_option image uploads.

http://www.axislighting.com/CMS/itemsDetail.php?1

and here is the code for that: 

<table width="350" align="center" cellpadding="2" cellspacing="2">
<tr>
<?php $maxCols=3;?>
<?php foreach ($itemsRecord['mounting_options'] as $upload): ?>
<td width="115" align="left"><?php if ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" alt="" width="<?php echo $upload['width'] ?>" border="0" /><br />
<?php endif ?></td>
<?php if (@++$count % $maxCols == 0): ?>
</tr>
<tr>
<?php endif ?>
<?php endforeach ?>
</tr>
</table>

How can I accomplish the columns when they are different fields?

Please advise.