Output to table display

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

By willydoit - June 23, 2010

Hi all,

We are currently working on a project for a client where he wants to keep a running result of football betting results which we want to be able to output in the format below, the table requires 6 columns but due to my limited css knowledge and cmsb I am unsure how we should go about it although I am pretty sure it is likely to be fairly straightforward once we have a handle on the basics. Each row is a complete record consisting of 6 elements. I am assuming that we can do the sort on a record number to keep everything in order without actually displaying the record number in the table, we simply need for the css to create the table of 6 columns generating a new row on every 7th item (I assume!!)

Any help or advice would be appreciated.



Thanks in advance

September 11[/#000000] Accrington[/#000000] 2.10[/#000000] W[/#000000] 110[/#000000] 5,110[/#000000] September 12[/#000000] Rochdale[/#000000] 2.00[/#000000] W[/#000000] 100[/#000000] 5,210[/#000000] [/#000000] Yeovil[/#000000] 2.20[/#000000] D[/#000000] -100[/#000000] 5,110[/#000000] [/#000000] Dagenham[/#000000] 2.10[/#000000] W[/#000000] 110[/#000000] 5,220[/#000000] [/#000000] Hartlepool[/#000000] 2.00[/#000000] D[/#000000] -100[/#000000] 5,120[/#000000] [/#000000] Gillingham[/#000000] 2.40[/#000000] W[/#000000] 140[/#000000] 5,260[/#000000] [/#000000] Bury[/#000000] 2.30[/#000000] L[/#000000] -100[/#000000] 5,160[/#000000]

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