472,125 Members | 1,428 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,125 software developers and data experts.

alternate row colors - NOT in a DB

I have a list of links that I ue on my page, I alternate background colors
for these links in a table, I usually do it using a DB but this list of link
is manually added into the page so my question, is it possible to alternate
the row colors automatic and have it created from a list of URL's?
Jul 17 '05 #1
5 2369
aznFETISH <ne**@aznfetish.com> wrote:
I have a list of links that I ue on my page, I alternate background colors
for these links in a table, I usually do it using a DB but this list of link
is manually added into the page so my question, is it possible to alternate
the row colors automatic and have it created from a list of URL's?


The answer is offcourse a simple yes. See the modulo operator (%).

BTW this is also possible in CSS (somehow (on decend browsers)) or with
clientside scripting.
Jul 17 '05 #2
I have the following code that will alternate the table cells, how can I
determine what is in each cell currently it just shows numbers, could this
be adapted to show a URL in each one?
<table border="1">
<?php
$row = 25;
$x = 1;
while ($x <= $row) {
if($x%2): $color = "#FFFFFF"; else: $color = "#CCCCCC"; endif;
print "<tr><td style=\"background-color: ".$color."\">Row
#".$x."</td></tr>\n";
$x++;
}
?>
</table>

"aznFETISH" <ne**@aznfetish.com> wrote in message
news:En*****************@tornado.tampabay.rr.com.. .
I have a list of links that I ue on my page, I alternate background colors
for these links in a table, I usually do it using a DB but this list of
link is manually added into the page so my question, is it possible to
alternate the row colors automatic and have it created from a list of
URL's?

Jul 17 '05 #3
aznFETISH wrote:
I have a list of links that I ue on my page, I alternate background colors for these links in a table, I usually do it using a DB but this list of link is manually added into the page so my question, is it possible to alternate the row colors automatic and have it created from a list of URL's?


http://in2.php.net/strings#44652

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #4
Thanks, so I would make the background color for the table cell

<table width="800%" border="0">
<tr bgcolor="<? $color = next($colors) or $color = reset($colors);
?> ">
<td>&nbsp;</td>
</tr>
<tr bgcolor="<? $color = next($colors) or $color = reset($colors);
?> ">
<td>&nbsp;</td>
</tr>
</table>
Is the above correct

<?php
$colours = array('#000000', '#808080', '#A0A0A0', '#FFFFFF');

// Get a colour
$color = next($colors) or $color = reset($colors);
?>

"R. Rajesh Jeba Anbiah" <ng**********@rediffmail.com> wrote in message
news:11********************@o13g2000cwo.googlegrou ps.com...
aznFETISH wrote:
I have a list of links that I ue on my page, I alternate background

colors
for these links in a table, I usually do it using a DB but this list

of link
is manually added into the page so my question, is it possible to

alternate
the row colors automatic and have it created from a list of URL's?


http://in2.php.net/strings#44652

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #5
"aznFETISH" <ne**@aznfetish.com> writes:
I have a list of links that I ue on my page, I alternate background colors
for these links in a table, I usually do it using a DB but this list of link
is manually added into the page so my question, is it possible to alternate
the row colors automatic and have it created from a list of URL's?

What you are looking for is known as a "zebra table". You can use css
or dhtml for this. See http://www.alistapart.com/articles/zebratables
.. Correct me if I did not follow your question.

--
Raj Shekhar Y! : Operations Engineer
MySQL DBA, programmer and slacker Y!IM : lunatech3007
home : http://rajshekhar.net blog : http://rajshekhar.net/blog/
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by madsgormlarsen | last post: by
reply views Thread by Paolo | last post: by
1 post views Thread by news | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.