GUI Code

  Home arrow GUI Code arrow Alternating Row Colors
GUI CODE

Alternating Row Colors
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
    Hello there This is one way someone can alternate table row colors. Makes the information much easier to scan/read. There may be a few typo's but the code should work properly:D

    By : shaker

    <html>
    <head>
    <title>Alternating Row Colors</title>
    </head>

    <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">

    <table width="300" height="400">

    <?

    // Connect to MySQL

    mysql_connect ('localhost', 'username', 'password')
    or die ("Can't connet to MySQL server.");

    mysql_select_db ('dbname');

    $result = mysql_query (SELECT * FROM table);

    if ($row = mysql_fetch_array($result)) {

    for ($i = 0; i < count($row); $i++) {

    // Set Table Row Color

    if ($i % 2) {

    echo "<tr bgcolor=B0C4DE>";
    } else {
    echo "<tr bgcolor=FOF8FF>";
    }

    // Now display our table cell info
    ?>

    <td><? echo $row["whatever"]; ?></td>
    </tr>

    <?
    } else {

    echo "<tr bgcolor=B0C4DE><td>Sorry, no records were found!</td></tr>";

    }

    ?>

    </table>
    </body>
    </html>
    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