SDP2006
01-31-2004, 02:23 PM
I've always wanted to know how to alternate row colors, but I couldn't ever understand the tutorials. So, for once, can someone modify the code below to give me alternating row colors? Hopefully I will memorize it and finally understand it.
<html>
<head>
<title>Link Tracker Hits</title>
<style type="text/css">
body { font-family: Lucida Sans Unicode, sans-serif; }
h2 { margin: 0; }
td { padding : 4px; }
</style>
</head>
<body bgproperties="fixed" background="../styleimgs/bg.gif" vlink="#0000FF" alink="#0000FF">
<h2>Link Tracker : Net-Riches.com</h2>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" bgcolor="white">
<tr>
<td width="14%">
<b>Category</b>
</td>
<td width="36%">
<b>Site Name</b>
</td>
<td width="43%">
<b>Link to Site</b>
</td>
<td width="7%">
<b>Clicks</b>
</td>
</tr>
<?php
$link = mysql_connect("$host","$user","$pass") or die("Could not connect to database!");
mysql_select_db("$db","$link") or die("Could not select database!");
$query = "SELECT id,des,cat,href,hits FROM linktracker ORDER BY hits DESC";
$result = mysql_query($query, $link) or die(mysql_error());
if($result){
if(mysql_num_rows($result) == 0){
echo "No information in database table!";
}
else{
while($row = mysql_fetch_assoc($result)){
$id = $_row['id'];
echo "<tr>";
echo "<td width='14%'>";
echo($row['cat']);
echo "</td>";
echo "<td width='36%'>";
echo($row['des']);
echo "</td>";
echo "<td width='43%'>";
echo '<a href="'.$row['href'].'">';
echo($row['href']);
echo "</a>";
echo "</td>";
echo "<td width='7%'>";
echo($row['hits']);
echo "</td>";
echo "</tr>";
}
}
}
?>
</table>
</body>
</html>
Thanks to all
<html>
<head>
<title>Link Tracker Hits</title>
<style type="text/css">
body { font-family: Lucida Sans Unicode, sans-serif; }
h2 { margin: 0; }
td { padding : 4px; }
</style>
</head>
<body bgproperties="fixed" background="../styleimgs/bg.gif" vlink="#0000FF" alink="#0000FF">
<h2>Link Tracker : Net-Riches.com</h2>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" bgcolor="white">
<tr>
<td width="14%">
<b>Category</b>
</td>
<td width="36%">
<b>Site Name</b>
</td>
<td width="43%">
<b>Link to Site</b>
</td>
<td width="7%">
<b>Clicks</b>
</td>
</tr>
<?php
$link = mysql_connect("$host","$user","$pass") or die("Could not connect to database!");
mysql_select_db("$db","$link") or die("Could not select database!");
$query = "SELECT id,des,cat,href,hits FROM linktracker ORDER BY hits DESC";
$result = mysql_query($query, $link) or die(mysql_error());
if($result){
if(mysql_num_rows($result) == 0){
echo "No information in database table!";
}
else{
while($row = mysql_fetch_assoc($result)){
$id = $_row['id'];
echo "<tr>";
echo "<td width='14%'>";
echo($row['cat']);
echo "</td>";
echo "<td width='36%'>";
echo($row['des']);
echo "</td>";
echo "<td width='43%'>";
echo '<a href="'.$row['href'].'">';
echo($row['href']);
echo "</a>";
echo "</td>";
echo "<td width='7%'>";
echo($row['hits']);
echo "</td>";
echo "</tr>";
}
}
}
?>
</table>
</body>
</html>
Thanks to all