Output to table display

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

Re: [willydoit] Output to table display

By rconring - June 23, 2010

Here is a basic HTML example of tabular data output. The CSS format is entirely up to your needs, but here is the basic mechanics for outputting records from the database to an HTML table. Hope this helps.

<table cellpadding="0" cellspacing="0" class="mas-table" style="border-style: solid; width: 100%">
<!-- Output the header row -->
<tr class="mas-header">
<td style="width: 50px; text-align: center;">Record</td>
<td style="width: 280px">Name</td>
<td style="width: 200px">Company</td>
<td style="width: 194px">Address</td>
<td style="width: 104px">City</td>
<td style="width: 26px">State</td>
<td>Zip Code</td>
</tr>
<!-- Loop through your records (per-page set in viewer code) -->
<?php foreach ($masterRecords as $record): ?>
<?php $bgColor = (@$bgColor == '#F0F0F0') ? '#FFFFFF' : '#F0F0F0'; ?>
<!-- Output the data row and alternate the row colors -->
<tr cllass="mas-data" bgcolor="<?php echo $bgColor ?>">
<!-- Output cells across the row (6 in your case) -->
<td>&nbsp;<a href="<?php echo $record['_link'] ?>"><?php echo $record['rec_id'] ?></a></td>
<td><?php echo $record['first_name'] ?> <?php echo $record['last_name'] ?></td>
<td><?php echo $record['company'] ?></td>
<td><?php echo $record['address'] ?></td>
<td><?php echo $record['city'] ?></td>
<td><?php echo $record['state'] ?></td>
<td><?php echo $record['zip_code'] ?></td>
</tr>
<?php endforeach ?>
</table>
Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987

Re: [willydoit] Output to table display

By rconring - June 23, 2010

I forgot to mention ... If you are new to CMSB, you may want to subscribe to Jerry Kornbluth's CMS Cookbook. Jerry has done an excellent job of accumulating a publication of tips, tricks, and examples of the most frequently encountered problems. I find it very useful and would recommend it to anyone new to CMSB.

http://www.thecmsbcookbook.com
Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987

Re: [rconring] Output to table display

By Chris - June 23, 2010 - edited: June 23, 2010

Hi willydoit,

Ron's example seems to be exactly what you're looking for. Did you get everything sorted out?
All the best,
Chris

Re: [rconring] Output to table display

By willydoit - June 24, 2010

Wow that's great, I shall place it in my snippets file of bits of helpful code, I am hoping to get on with this today so will let you know if I have any issues, thanks again this is great and very helpful.