473,382 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 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 2473
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: madsgormlarsen | last post by:
Hi I am making a html table builder, and would like every second row to be blue. So for that purpose I need a number that changes on every iteration of a while loop, for exampel so that a value...
0
by: Paolo | last post by:
Hi to all, could you please help me with this issue? I'd like to have the rows of a VB6 ADO grid bound to a db painted with an alternate background and foreground colors. I'd like to have the odd...
5
by: Matt | last post by:
I want to produce colors in alternate rows in the table. The following will produce blue color on every row. So my problem is to figure out to count the records. If it is odd record, then do <tr...
1
by: news | last post by:
Hi all, How do you implement alternate line colors in ms access datasheet view Regards Joe --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system...
4
by: Amy | last post by:
I need some help. I have this table with alternate row colors. Class gray and class white. I have javascript that do highlight when mouseover row ... and onclick to select row and highlight it...
1
by: pradheepayyanar | last post by:
Dear All i have dynamic generation of <table> rt now i have done the <TR> with alternate colors which is a dynamic table. my requirement is that for every cumulative <tr> i need different color....
5
by: Michael R | last post by:
Searching the net I've found a simple technique to add row numbers and alternate colors (for the even and the uneven row) to a continuous form. 1st step: Create a textbox, send it to background...
2
by: B. | last post by:
I am able to set the alternate row color using AlternatingRowsDefaultCellStyle. however, if my grid is not fully filled, the alternate row color will not apply for blank rows. How can I fill the...
2
by: Wayne | last post by:
Has anyone found the "Alternate Background Color" property in Access 2007 forms to be buggy? As I scroll a continuous form that is using an alternate background color for every second record, the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.