WebmasterSite.net: PHP scripts to enable your creativity
WSN Links PHP Directory Software
PHP Scripts Webmaster Links Support Forums

Register | Forgot Password

Alternating dynamic table row color

Version: 3.15
printPrint


Alternating dynamic table row color
wizard
Member

Usergroup: Customer
Joined: Jan 15, 2005
Total Topics: 7
Total Posts: 20
Posted 06/21/05 - 10:30 AM:
quote post
#1
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
Administrator
Avatar

Usergroup: Administrator
Joined: Dec 21, 2001
Location: Northern California
Total Topics: 57
Total Posts: 6339
Posted 06/22/05 - 05:11 AM:
quote post
#2
Some PHP,
<? if ({LINKNUMBER} % 2) { ?>
<tr background color #1>
<? } else { ?>
<tr background color #2>
<? } ?>

should do it.

"Do things you love doing, because then it ain't work. Don't do something you don't really enjoy, because you're never going to work hard enough at it." - Bob Young, founder of Red Hat
wizard
Member

Usergroup: Customer
Joined: Jan 15, 2005
Total Topics: 7
Total Posts: 20
Posted 06/22/05 - 07:35 AM:
quote post
#3
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 Posts: 20
Posted 06/22/05 - 09:45 PM:
quote post
#4
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 Posts: 20
Posted 06/22/05 - 09:52 PM:
quote post
#5
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


You don't have permission to post.

Please login or register.

   
 
© 2008 Paul Knierim. All rights reserved.