View Single Post
Old 04-08-2006, 02:32 AM   · #1
asgsoft
NamePros Regular
 
asgsoft's Avatar
 
Location: At Home
Trader Rating: (36)
Join Date: Sep 2005
Posts: 821
NP$: 990.10 (Donate)
asgsoft is just really niceasgsoft is just really niceasgsoft is just really niceasgsoft is just really niceasgsoft is just really nice
Alternating row colours

Have you ever wanted to make a table with alternating row colours?

Well I did it for a site and thought it would be great to share it. Here

PHP Code:
<?php
//connect to db and select table
$db1 = mysql_connect("host", "user", "pass");
mysql_select_db("$db",$db1);
$table = "tablename"; //table name


$list = mysql_query("SELECT * FROM `$table` ORDER BY `coulmn_name` ASC "); // the SQL of the table you will show
echo"<h3><p align=center> $table <p></h3>"; //title for the page
echo('<table width="500px" height="110px" style="font-family: Verdana; border: 1px solid black;" align="center" cellpadding="2" cellspacing="1" border="0">'); //add the table
echo('<tr align="center"><td><b><u>Date</u></b></td><td><b><u>description</u></b></td></tr>'); // top row with the titles
while($get=mysql_fetch_array($list))
{
//chooses colous
if ($color == "CCFFCC")
{
$color = "FFFFFF";//change the code
}
else
{
$color = "CCFFCC"; //change the code
}

echo(
'<tr bgcolor=#'.$color.' align="center">  <td>'. $get['Date'] .'</td><td>'. $get['description'] .'</td></tr>');  //add the contents
}
echo(
"</table>"); //finish the table

?>


See it on action at: http://www.asgsoft.net/mosque/view%...20a%20month.php


Please register or log-in into NamePros to hide ads
asgsoft is offline   Reply With Quote
Site Sponsors
Traffic Down Under Find out how! EscrowDNS
Advertise your business at NamePros
All times are GMT -7. The time now is 12:32 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.