473,574 Members | 2,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2497
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=\"backgro und-color: ".$color."\">Ro w
#".$x."</td></tr>\n";
$x++;
}
?>
</table>

"aznFETISH" <ne**@aznfetish .com> wrote in message
news:En******** *********@torna do.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**********@r ediffmail.com> wrote in message
news:11******** ************@o1 3g2000cwo.googl egroups.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
8891
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 is 0 then 1 then 0 a so forth. Any suggestions ? Mads
0
3435
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 rows with a x color and the even rows with a y color. What kind of grid do I have to use? And how can I do it? Moreover, I'd like to choose custom...
5
6421
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 bgcolor="blue">, otherwise, don't do anything, and it will output colors in alternate rows. I tried to use count, but doesn't work. Any ideas?...
1
4634
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 (http://www.grisoft.com). Version: 6.0.512 / Virus Database: 309 - Release Date: 20/08/2003
4
19543
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 with another color. Also created a class called "Selected". You can only select a row at a time. My problem is, if a row is preselected, when...
1
1843
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. ex. <table> <tr> <td>a</td><td>1</td> </tr> <tr> <td>b</td><td>2</td> </tr>
5
27548
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 and select the first color. .ControlSouce =fRowNum(False) .Name = RowNum 2nd step: Add the following function to the form module: (for row...
2
6168
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 blank rows with alternate color as well. Thanks.
2
6030
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 background colors get confused and go haywire. Nice feature if it worked propertly!
0
7738
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8079
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7833
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8118
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5635
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5321
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3756
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1081
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.