GUI Code

  Home arrow GUI Code arrow Another Alternate Row color
GUI CODE

Another Alternate Row color
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    2002-05-21

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement
    This is a function that will allow you to display alternate table row colors.

    By : hurlic

    <?php

    // Displays alternate table row colors
    function row_color($i){
    $bg1 = "#0099FF"; // color one
    $bg2 = "#336699"; // color two

    if ( $i%2 ) {
    return $bg1;
    } else {
    return $bg2;
    }
    }

    //DB connection
    $connection = mysql_connect("localhost","userName","password");
    $db = mysql_select_db("databaseName");

    $sql = "select * from tableName"; // Database Query
    $result = mysql_query("$sql"); // Database Query result

    // Starts the table
    echo "<table bgcolor=#FFFFFF border=0 cellpadding=1 cellspacing=1>\n";

    // Create the contents of the table.
    for( $i = 0; $i < $row = mysql_fetch_array($result); $i++){
    echo "<TR>\n"
    ."<TD bgcolor=".row_color($i).">".$row["fname"]."</TD>\n"
    ."<TD bgcolor=".row_color($i).">".$row["lname"]."</TD>\n"
    ."</TR>";
    }
    echo "</TABLE>"
    ?>
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More GUI Code Articles
    More By Codewalkers

    blog comments powered by Disqus

    GUI CODE ARTICLES

    - PHP Image Manipulation Class 1.0
    - Simple PHP-CAPTCHA,
    - dPhoto
    - nice looking dir index'r
    - Colorpicker
    - Exposure Gallery build 1226
    - Dynamic "AQUA" Buttons
    - AdminTool|1.0 for Exposure Gallery
    - Exposure Gallery v1.2
    - Crop Canvas
    - Display all available background colours
    - Exposure Gallery v1.0
    - JPEG Directory Thumbnail system (Apect ratio)
    - JPEG Directory thumbnail system
    - Change Background Color each day


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 10 - Follow our Sitemap