By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,822 Members | 729 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,822 IT Pros & Developers. It's quick & easy.

alternate row colors - NOT in a DB

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
"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.