Hi there!
I have a so called "buyers guide" where people can find different snowboards. They can search boards with their weight and etc. My result page is pretty ugly.
How can I make table where every other row is grey and every other is white (for example)! My code look like this:
<?php
$db = mysql_connect("?", "?", "?");
mysql_select_db("snowboards",$db);
if ($Manufacter == "")
{$Manufacter = '%';}
if ($Model == "")
{$Model = '%';}
if ($Lenght1 == "")
{$Lenght1 = '%';}
if ($Lenght2 == "")
{$Lenght2 = '%';}
if ($Usage == "")
{$Usage = '%';}
if ($Made == "")
{$Made = '%';}
if ($Sizeab == "")
{$Sizeab = '%';}
if ($width_nose == "")
{$width_nose = '%';}
if ($width_mid == "")
{$width_mid = '%';}
if ($width_tail == "")
{$width_tail = '%';}
if ($weight == "")
{$weight = '%';}
if ($Price == "")
{$Price = '%';}
if ($Price == "1")
{$Price = '1%';}
if ($Price == "2")
{$Price = '2%';}
if ($Price == "3")
{$Price = '3%';}
if ($Price == "4")
{$Price = '4%';}
if ($id) {
$result = mysql_query("SELECT * FROM boards WHERE id=$id",$db);
$myrow = mysql_fetch_array($result);
printf("<TABLE CELLPADDING=2 CELLSPACING=2 border=1><tr><td><b>Board Manufacter:</b></td><td>%s<br></td><td rowspan=11>%s</td></tr>", $myrow["Manufacter"], $myrow["picture"]);
printf("<td><b>Model:</b></td><td> %s\n<br></td></tr>", $myrow["Model"]);
printf("<td><b>Lenght:</b></td><td> %s\n<br></td></tr>", $myrow["lenght"]);
printf("<td><b>Usage:</b></td><td> %s\n<br></td></tr>", $myrow["Usage"]);
printf("<td><b>Board Made:</b></td><td> %s\n<br></td></tr>", $myrow["Made"]);
printf("<td><b>Board Size:</b></td><td> %s\n<br></td></tr>", $myrow["Sizeab"]);
printf("<td><b>width nose:</b></td><td> %s\n<br></td></tr>", $myrow["width_nose"]);
printf("<td><b>width keski:</b></td><td> %s\n<br></td></tr>", $myrow["width_mid"]);
printf("<td><b>width tail:</b></td><td> %s\n<br></td></tr>", $myrow["width_tail"]);
printf("<td><b>weight range:</b></td><td> %s - %s\n kg<br></td></tr>", $myrow["weight_min"], $myrow["weight_max"]);
printf("<td><b>Price:</b></td><td> %s\n mk<br></td></tr></table>", $myrow["Price"]);
// printf($myrow["picture"]);
print "<br><br><A href=javascript:history.go(-1)><font face=Tahoma size=2>Back</font></A>";
} else {
$result = mysql_query("SELECT * FROM boards
WHERE Manufacter LIKE '$Manufacter%'
AND Model LIKE '$Model%'
AND Usage LIKE '$Usage%'
AND Made LIKE '$Made%'
AND Sizeab LIKE '$Sizeab%'
AND width_nose LIKE '$width_nose%'
AND width_mid LIKE '$width_mid%'
AND width_tail LIKE '$width_tail%'
AND weight_min <= '$weight%'
AND weight_max >= '$weight%'
AND Price LIKE '$Price'
AND lenght >= '$Lenght1' AND lenght <= '$Lenght2'
ORDER BY Manufacter",$db);
if ($myrow = mysql_fetch_array($result)) {
if(strcmp($result, ''))
$number=mysql_numrows($result);
else
$number=0;
// display list if there are records to display
print "Serch found <b>$number</b> snowboards\n<br><br>";
print "<table border=1>";
print "<tr><td><b>Manufacter</td><td><b>Model</td><td><b>lenght</td><td><b>Price</td><td><b>picture</td></tr>";
do {
printf("<tr><td nowrap width=100><a href=\"%s?id=%s\">%s</a></td>", $PHP_SELF, $myrow["id"], $myrow["Manufacter"]);
printf("<td width=150 nowrap><a href=\"%s?id=%s\">%s</a></td>", $PHP_SELF, $myrow["id"], $myrow["Model"]);
printf("<td width=50 nowrap><a href=\"%s?id=%s\">%s</a></td>", $PHP_SELF, $myrow["id"], $myrow["lenght"]);
printf("<td width=50 nowrap><a href=\"%s?id=%s\">%s</a></td>", $PHP_SELF, $myrow["id"], $myrow["Price"]);
printf("<td width=50 nowrap><a href=\"%s?id=%s\">picture</a></td></tr>", $PHP_SELF, $myrow["id"]);
} while ($myrow = mysql_fetch_array($result));
} else {
// no records to display
echo "Nothing found!<br>";
print "<br><br><A href=javascript:history.go(-1)><font face=Tahoma size=2>back</font></A>";
}
}
print "</table>";
?>
Page is at www.ostajanopas.cjb.net and there select 'etsi lumilautoja' and press 'hae laudat'