Zend - The PHP Company




Tables

Add Code


Alt background color  

Type: code fragment
Added by: adamprince1
Entered: 20/08/2005
Last modified: 08/12/2004
Rating: - (fewer than 3 votes)
Views: 3376
KISS = "keep it simple stupid" This is a pretty simple if statement that I did for a cobol program works like a champ


<?php
//the swicth is set to odd and the if statement alternates it and the color
    
$switch "odd";
    while(
$row  mysql_fetch_object($result)) {
        echo 
$switch;
      
/////////////////////////////////////////////
      //   if switch odd to even
      //   Var $switch even : odd
      //   Var $color that is swithced
      /////////////////////////////////////////////
        
if ($switch == "odd")
           {
             
$color ="#000033";
             
$switch "even";
           }
        else
           {
             
$color "#CCCCC";
             
$switch "odd";
           }
        
// Var $color that is alternated
        
echo "<tr bgcolor='$color'>";
        echo 
"<td>".$row->ex_Name."</td>";
        echo 
"<td>".$row->ex_Des."</td>";
        echo 
"</tr>";
    }
    echo 
"</table>";
?>


Usage Example




Rate This Script





Search



This Category All Categories