hi i have a dynamic table.i want to rows in alternative colours

$nr0 displays the no of rows fetched

while ($row=mysql_fetch_array($rs))
    {

        /////////////////////////////////////////////////////////////////////////////////
        //This is used to show the serial number on the page as well as to count it up
        //so that we can get the next page's starting row number when it exits the while
        //loop after fullfilling the above SQL criteria.
        /////////////////////////////////////////////////////////////////////////////////
        $cps = $cps +1;

  if($nr0 %2 == 0)
{
echo "<tr>";
echo "<td>";
echo "<table  bgcolor='#ffffff' border='1'>";
 echo "<tr><td><font face='verdana' size=1><strong>Resume Title : </strong></font><a href='myresume1.php?id=".$row[0]."'>".$row[2]."</td></tr>";
echo "<tr><td><font face='verdana' size=1><strong>Industry Type: </strong></font>".$row[4]."</td><td><font face='verdana' size=1><strong>Career Level:  </strong></font>".$row[5]."</td></tr>";
echo "</td>";
echo "</tr>";
echo "</table>";

}
 else
{
echo "<tr>";
echo"<td>";
echo "<table bgcolor='#66CC66' border='1'>";
echo "<tr><td><font face='verdana' size=1><strong>Resume Title : </strong></font><a href='myresume1.php?id=".$row[0]."'>".$row[2]."</td></tr>";
echo "<tr><td><font face='verdana' size=1><strong>Industry Type: </strong></font>".$row[4]."</td><td><font face='verdana' size=1><strong>Career Level:  </strong></font>".$row[5]."</td></tr>";
echo "</td>";
echo "</tr>";
echo "</table>";}

  }

it is not working......it is just printing the else part...........

instead, initialise $nr0 to 0 outside while loop. initialise $nr0 at the end of while loop.

$nr0 contains the no of rows fetched

Do you want alternate colors for columns ?

row.....ya i found out thank for relying

$i=$nr0;


while ($row=mysql_fetch_array($rs))
{


/////////////////////////////////////////////////////////////////////////////////
//This is used to show the serial number on the page as well as to count it up
//so that we can get the next page's starting row number when it exits the while
//loop after fullfilling the above SQL criteria.
/////////////////////////////////////////////////////////////////////////////////
$cps = $cps +1;


if($i %2 == 0)
{
echo "<tr>";
echo "<td>";
echo "<table  bgcolor='#f4eded' width='90%'  align='center' border='0'>";
echo "<tr><td width='45%'><font face='verdana' size=1><strong>Resume Title : </strong></font><a href='myresume1.php?id=".$row[0]."'>".$row[2]."</td></tr>";
echo "<tr><td width='45%'><font face='verdana' size=1><strong>Industry Type: </strong></font>".$row[4]."</td><td><font face='verdana' size=1><strong>Career Level:  </strong></font>".$row[5]."</td></tr>";
echo "</table>";
echo "</td>";
echo "</tr>";



}
else if($i %2 == 1)
{
echo "<tr>";
echo "<td>";
echo "<table bgcolor='#669999' width='90%'  border='0' align='center'>";
echo "<tr><td width='45%'><font face='verdana' size=1><strong>Resume Title : </strong></font><a href='myresume1.php?id=".$row[0]."'>".$row[2]."</td></tr>";
echo "<tr><td width='45%'><font face='verdana' size=1><strong>Industry Type: </strong></font>".$row[4]."</td><td><font face='verdana' size=1><strong>Career Level:  </strong></font>".$row[5]."</td></tr>";
echo "</table>";
echo "</td>";
echo "</tr>";


}
$i--;


}

:) Good !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.