Is there some way to make a table have alternating colors for rows when
you're generating the table data with a WHILE statement?
You know, row 1 has a gray BG, row 2 is white, row 3 is gray, 4 is white,
etc, for as long as there's data.
Here's what I'm using right now:
$query_RSwho = "SELECT * FROM tbl_indv ORDER BY name ASC";
$RSwho = @mysql_query($q uery_RSwho, $connection) or die("Couldn't query: "
.. mysql_error());
while ($row_RSwho = mysql_fetch_arr ay($RSwho)) {
if ($row_RSwho['name'] != "X") {
$names .= "<tr align=left><td
width=120>".$ro w_RSwho['name']."</td><td
align=left>&nbs p;-- ".$row_RS who ['email']."</td></tr>";
}
}
So, in that WHILE section, is there a way to alternate bgcolor table cell
tags?
If there's a web site, or something, just point me? =)
Thanks!
Liam
Jul 17 '05
12 2896
In article <yvJ2c.497761$I 06.5347103@attb i_s01>,
"LRW" <dr***@NOSPAHMc elticbear.com> wrote: Is there some way to make a table have alternating colors for rows when you're generating the table data with a WHILE statement? You know, row 1 has a gray BG, row 2 is white, row 3 is gray, 4 is white, etc, for as long as there's data. Here's what I'm using right now:
$query_RSwho = "SELECT * FROM tbl_indv ORDER BY name ASC"; $RSwho = @mysql_query($q uery_RSwho, $connection) or die("Couldn't query: " . mysql_error()); while ($row_RSwho = mysql_fetch_arr ay($RSwho)) { if ($row_RSwho['name'] != "X") { $names .= "<tr align=left><td width=120>".$ro w_RSwho['name']."</td><td align=left>&nbs p;-- ".$row_RS who ['email']."</td></tr>"; } }
So, in that WHILE section, is there a way to alternate bgcolor table cell tags? If there's a web site, or something, just point me? =) Thanks! Liam
I like compact solutions:
while ($row_RSwho = mysql_fetch_arr ay($RSwho)) {
$bg = $nr++ % 2 ? "ffffff" : "eeeeee";
print "<tr bgcolor='#$bg'> ....";
}
But as others have said - use stylesheets:
while ($row_RSwho = mysql_fetch_arr ay($RSwho)) {
$bg = $nr++ % 2 ? "even" : "odd";
print "<tr class='$bg'>... .";
}
--
Sandman[.net]
While the city slept, LRW <dr***@NOSPAHMc elticbear.com> feverishly typed: Is there some way to make a table have alternating colors for rows when you're generating the table data with a WHILE statement? You know, row 1 has a gray BG, row 2 is white, row 3 is gray, 4 is white, etc, for as long as there's data.
[...]
I've just quickly knocked this up: http://www.nigenet.org.uk/stuff/phpRowColours.php
Hope that helps.
Cheers,
Nige
--
Nigel Moss.
Email address is not valid. ni***@nigenetDO G.org.uk. Take the dog out! http://www.nigenet.org.uk | Boycott E$$O!! http://www.stopesso.com
In the land of the blind, the one-eyed man is very, very busy!
LRW <dr***@NOSPAHMc elticbear.com> wrote: Is there some way to make a table have alternating colors for rows when you're generating the table data with a WHILE statement?
You should check this out: http://www.alistapart.com/articles/zebratables/
bblackmoor
2004-03-17 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: bettyann |
last post by:
i am using templates via HTML_Template_IT to create a table from the
results of a mysql query. i wanted to change the background image of
alternating rows in the table. i thought i could do this by defining
two different blocks in the template file and setting the current block
based on ( $thisRowNum % 2 ).
when the final table is displayed, all the "even" rows are displayed
before all the "odd" rows. in other words, the rows are not...
|
by: Ralph Snart |
last post by:
Is there a way to alternate table row colors without using the
position() mod 2 trick? I'm in a series of nested xsl:for-each
elements, about 3 deep, and I want to alternate the table row
color all the way through. position() resets to 1 whenever
the inner for-each loops around, of course.
Example code:
<xsl:for-each select="/games/game) = 1]">
<xsl:sort select="platform"/>
|
by: Matt Kruse |
last post by:
http://www.mattkruse.com/temp/css_expressions.html
One of the standard CSS questions is "how can I shade every other table row
a different color with CSS?"
The answers are usually 1) you can't (yet), 2) put a class on every other
tr, or 3) use javascript to do the styling for you.
Well, I've been playing the CSS expressions quite a bit lately and I've
found a much simpler solution which works in IE5.5+, using "expressions". If
|
by: Max Weebler |
last post by:
Hi,
I have a datagrid built that has an alternating item style that sets the
backcolor and ForeColor of its rows. I have 4 template columns. One of them
has a LinkButton embedded in it to perform updates. All the styles that are
set are being followed by all templated columns with the exception for the
update column. The update column does set the BackColor appropriately but
when setting its ForeColor the LinkButton's color is blue and...
|
by: Steve Bottoms |
last post by:
Hi, all!
How does one prevent table cell background colors from alternating between
grey and white? I've dropped a basic table control on an ASP.Net page
(using VB.Net codebehind), and dynamically creating rows and cells. However,
I can't seem to get the blasted thing to stop alternating the background
colors on every other row! I've tried setting the cell.BackColor property,
but the value is just getting ignored! Also tried on...
| |
by: |
last post by:
I'm making admin forms. I'm wondering if there is a way to have the server
programmatically assign alternating colors in a regular table (not a
datalist control). I notice ASP.NET 2 offers a runat="server" attribute on
tables, leading me to believe that this should be possible.
Any ideas? I'm using C#.
Thanks,
-KF
|
by: eric.goforth |
last post by:
Hello,
I have some xml data that look like:
<currencysummary rec_count="16">
<currency>
<currency_description>$</_currency_description>
<currency_code>1</_currency_code>
</currency>
<currency>
|
by: clintw |
last post by:
Hi all,
I've been doing my head in trying to get this to work, but I keep running into a snag. Basically I have a database table with a list of events for the year, with fields for Month, Event Description, FullDate (used for sorting). When I input the result set into a HTML table, this works fine, alternating backgrounds colors for the individual rows is no problem - my problem comes in trying to alternate the background colors by Month...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |