Table Highlighting

5 posts by 4 authors in: Forums > CMS Builder
Last Post: May 18, 2010   (RSS)

By (Deleted User) - May 17, 2010

I am setting up a table system but can not remember how to get the table to highlight every second line.

For example:

Date Time
24 2pm <-- white background
28 1pm <-- grey background
30 12pm <-- white background
31 5pm <-- grey background

Something like that.

Re: [hegadmin] Table Highlighting

By Jason - May 17, 2010

Hi,

Are you currently outputting a table without highlighting?
If you could post the code you have so far (or attach your .php file) I can help you do this.

Thanks.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [hegadmin] Table Highlighting

By Kenny - May 18, 2010

You'll need to adapt to your fields, but try this:

<h3>Contact Us</h3>
<table>
<tr>
<th>title</th>
<th>name</th>
<th>phone</th>
<th>email</th>
</tr>
<?php foreach ($contact_listRecords as $record): ?>
<?php $bgColor = (@$bgColor == '#F8F8F8') ? '#EFEFEF' : '#F8F8F8'; ?>
<tr bgcolor="<?php echo $bgColor ?>">
<td><?php echo $record['title'] ?></td>
<td><?php echo $record['name'] ?></td>
<td><?php echo $record['phone'] ?></td>
<td><a href="mailto:<?php echo $record['email'] ?>"><?php echo $record['email'] ?></a></td>
</tr>
<?php endforeach; ?>
</table>



Kenny

Re: [hegadmin] Table Highlighting

By rconring - May 18, 2010

Here is a simplified example ... set alternate colors at top of foreach loop, then echo the color on each row.
Hope this helps.

<table>
<?php foreach ($whateverRecords as $record): ?>
<?php $bgColor = (@$bgColor == '#F0F0F0') ? '#FFFFFF' : '#F0F0F0'; ?>
<tr bgcolor="<?php echo $bgColor ?>"> <td>
<?php echo $record['name'] ?>
</td>
<td>
<a href="mailto:<?php echo $record['email'] ?>">Send Email</a>
</td>
</tr>
<?php endforeach ?>
</table>
Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987