The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Alternating Table Colours
Discuss Alternating Table Colours in the PHP Development forum on Dev Shed. Alternating Table Colours PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

May 29th, 2000, 05:20 AM
|
|
BrainFreeze
|
|
Join Date: May 2000
Location: London
Posts: 318
Time spent in forums: 3 h 41 m 9 sec
Reputation Power: 13
|
|
|
I am producing a league table, that is ordered by points, I wish to smarten the table up by alternating the row colours, i am a newbie - and have looked everywhere for an easy solution, can anyone help me please >
Also if my league had 10 age groups, would it be easier to have 10 pages with the php calling each table out, or is there some other ingenious way of knowing what the person wants to see.
|

May 29th, 2000, 11:31 AM
|
|
Junior Member
|
|
Join Date: May 2000
Posts: 27
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
This looks like a standard HTML solution
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
<TABLE>
<TR>
<TD BGCOLOR="#0000FF">Hello There</TD>
</TR>
</TABLE>
[/code]
gives you a perfect table column with a Blue background
|

May 29th, 2000, 11:36 AM
|
|
Junior Member
|
|
Join Date: May 2000
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by iwarner:
I am producing a league table, that is ordered by points, I wish to smarten the table up by alternating the row colours, i am a newbie - and have looked everywhere for an easy solution, can anyone help me please >
[/quote]
You can adapt the following code to create a table with alternating row colours:
<table>
<?
$row = 0;
$search = mysql_query("select some_columns from some_tables");
while ($search_values = mysql_fetch_array($search)) {
$row++;
if (floor($row/2) == ($row/2)) {
echo '<tr bgcolor="#ffffff">' . "n"; // in white
} else {
echo '<tr bgcolor="#f4f7fd">' . "n"; // in light blue
}
echo ' <td>$search_values["column1"]</td>
echo '</tr>' . "n";
}
?>
</table>
|

May 29th, 2000, 09:21 PM
|
|
Junior Member
|
|
Join Date: May 2000
Posts: 24
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Also if my league had 10 age groups, would it be easier to have 10 pages with the php calling each table out, or is there some other ingenious way of knowing what the person wants to see.
if you have 10 pages then that is 10x the upkeep. I think i can speak for a lot of programmers when i say that i am lazy as hell. I would do it like this:
http://mydomain.com/teams.php3?team=bears
then in your php query the database for $team and display their results.
|

May 29th, 2000, 09:47 PM
|
|
Contributing User
|
|
Join Date: May 2000
Posts: 33
Time spent in forums: < 1 sec
Reputation Power: 14
|
|
|
Another solution to do alternating colors would be to check if $rownumber % 2 != 1, write one HTML color string, else write another.
|

May 30th, 2000, 09:47 AM
|
|
BrainFreeze
|
|
Join Date: May 2000
Location: London
Posts: 318
Time spent in forums: 3 h 41 m 9 sec
Reputation Power: 13
|
|
|
Cheers guys - help is appreciated, I will crack on with that tonight.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|