Webmastersite.net
Register Log In

Alternating dynamic table row color

Comments on Alternating dynamic table row color

wizard
Member

Usergroup: Customer
Joined: Jan 15, 2005

Total Topics: 7
Total Comments: 20
wizard
Posted Jun 21, 2005 - 11:30 AM:

Was wondering if there was a way to alternate table row background color when links are displayed dynamincally using the <!-- BEGIN REGULAR LINKS --> comment.

the links are displayed dynmically in this simplified version:

<table>
<!-- BEGIN REGULAR LINKS -->
<tr background color #1>
<td>All the link fields you want displayed </td>
</tr>
<!-- END REGULAR LINKS -->
</table>

but I want the links be displayed in rows that have alternating background colors

<tr background color #1>
<td>All the link fields you want displayed </td>
</tr>
<tr background color #2>
<td>All the link fields you want displayed </td>
</tr>

is there a way to do this when the links are displayed dynamically?
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted Jun 22, 2005 - 6:11 AM:

Some PHP,
<? if ({LINKNUMBER} % 2) { ?>
<tr background color #1>
<? } else { ?>
<tr background color #2>
<? } ?>

should do it.
wizard
Member

Usergroup: Customer
Joined: Jan 15, 2005

Total Topics: 7
Total Comments: 20
wizard
Posted Jun 22, 2005 - 8:35 AM:

it sort of works however what i get is alternating row colors and then blocks of 2 or more rows that are same color as seen here .... http://wizardofchips.com
wizard
Member

Usergroup: Customer
Joined: Jan 15, 2005

Total Topics: 7
Total Comments: 20
wizard
Posted Jun 22, 2005 - 10:45 PM:

oops i forgot to generate a static copy of my directory so if anyone looked at it all they saw was table rows all one color. Ive updated it now you can see what i was talking about in my last post.... alternating colors for a couple of rows, then a block of two or three rows that are same color... looks aweful hehe

wizard
Member

Usergroup: Customer
Joined: Jan 15, 2005

Total Topics: 7
Total Comments: 20
wizard
Posted Jun 22, 2005 - 10:52 PM:

ok I fixed the output for a toplist to alternate table row colors by changing {LINKNUMBER} in Paul's example to {NUMBER} that was easy.

I suspect that {LINKNUMBER} will work fine for any output that was generated by the <!-- BEGIN REGULAR --> call in my other templates.
Search thread for
Download thread as
  • 0/5
  • 1
  • 2
  • 3
  • 4
  • 5



This thread is closed, so you cannot post a reply.