GUI Code

  Home arrow GUI Code arrow Alternate Row Colours
GUI CODE

Alternate Row Colours
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2002-01-18

    Table of Contents:

     
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    advertisement
    A script to alternate row colours when getting information from a MySQL database.

    By : james

    <?

    // Header rows
    print ("<body bgcolor=black text=white>");
    print ("<table border=1 width=100%>
    <tr>
    <td width=18%><font face=Verdana, Arial, Helvetica, sans-serif size=2><b>Name</b></font></td>
    <td width=82%><font face=Verdana, Arial, Helvetica, sans-serif
    size=2><b>Email</b></font></td>");

    // DB connection information
    $connection = mysql_connect("localhost","username","password");
    $db = mysql_select_db("database", $connection);

    // SQL Query
    $sql = mysql_query("SELECT * FROM table");

    $alternate = "2"; // number of alternating rows
    while ($row = mysql_fetch_array($sql)) {
    $name = $row["name"]; //name of field
    $email = $row["email"];

    if ($alternate == "1") {
    $colour = "#000000";
    $alternate = "2";
    }

    else {
    $colour = "#464646";
    $alternate = "1";
    }

    print ("</tr><tr><td bgcolor=$colour width=18%><font face=Verdana, Arial, Helvetica,
    sans-serif size=2>$name</font></td><td bgcolor=$colour width=82%>
    <font face=Verdana, Arial, Helvetica, sans-serif size=2>$email</font></td>
    </tr>");
    }
    print ("</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 7 - Follow our Sitemap