Can lists data be displayed in tables?

3 posts by 2 authors in: Forums > CMS Builder
Last Post: January 30, 2009   (RSS)

Re: [markr] Can lists data be displayed in tables?

By Kenny - January 30, 2009 - edited: January 30, 2009

markr -

Here's a sample of list data in a table. You can modify it with your fields. It doesn't have any styling, so you will have to add that, too.

<table border="0" cellpadding="3" cellspacing="3" id="table5" width="561">
<tr>
<td>Domain Name</td>
<td>Username</td>
<td>Site Info</td>
<td>Site Software</td>
</tr>

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

<tr>
<td><?php echo $record['domain'] ?></td>
<td><?php echo $record['username'] ?></td>
<td><a href="<?php echo $record['_link'] ?>">View</a></td>
<td><a href="<?php echo $record['domain'] ?>">View</a></td>
</tr>

<?php endforeach; ?>

</table>


Notice the <tr> and </tr> are in between the foreach and endforeach statements. This is telling the program to generate this set of code for each entry in the database.

In this case, it is generating a "row" in a table over and over again.

Let me know if that helps

Kenny

Re: [sagentic] Can lists data be displayed in tables?

By markr - January 30, 2009

Makes sense. Works perfectly.