PHP Snippets

Name:Alternating Background Color
Description: Alternating background color. This would be useful if you have large text into a table so it can easily be read.

Code below...
> <?php 

  
//You can change the hex colors (currently set to #E5E5E5 and #C1C1C1)
  //This is just a simple example, hopefully you get the idea.

  
$i 1;
  
//Number of rows
  
$r 20;
  
//Background color
  
$bg "#E5E5E5";
  
   echo 
"<table>\n";
     while (
$i $r) {
       if (
$bg == "#E5E5E5") {  
         
//Alternate background color
         
$bg "#C1C1C1";
       }
       else { 
         
$bg "#E5E5E5";
       }
      
//Results
      
echo "<tr>\n";
      echo 
"<td bgcolor=\"$bg\">Hi Hello How are you</td>\n";
      echo 
"</tr>\n";
      
$i++;
     }
  echo 
"</table>";

?>

« Back to PHP Snippets

Home | Site Map | Privacy Policy | Advertising | Contact Us
Copyright © 2006-2014 r2xDesign.net - All Rights Reserved.
eXTReMe Tracker