#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    east lansing,MI
    Posts
    9
    Rep Power
    0
    ur prob. all laughing at this easy *** question ... but for some reason i cant fig. it out.

    i know how to find even (and odd) numbers in c++ (using the %).

    how the hell do u do it in php tho...

    im trying to alternate the bgcolor of a row in a table (from #CCCCCC to #FFFFFF)

    here is my code..

    if ($row = mysql_fetch_array($result)) {
    $x=0;
    echo "<table width=200 border=1 cellspacing=0 cellpadding=4>";
    do {

    if (($x%2)==0){$color="#FFFFFF";}
    else {$color="#CCCCCC";}
    echo "<tr bgcolor=$color><td>";
    print $row["name"];
    print ("</td><td>");
    print $row["email"];
    print ("</td></tr>");
    $x=$x+1;
    } while($row = mysql_fetch_array($result));
    print ("</table>");
    } else {print "Sorry, no records were found!";

    THX in advance!!
    ryan
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    east lansing,MI
    Posts
    9
    Rep Power
    0
    wahooo...

    2 sec after i posted this i found out the error...(i was missing a ; - dont u hate that ****)

    the script i posted as my example works (for anyone else who is a newbie like me and would like to borrow it)

  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    DFW TX
    Posts
    1
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by rynop2000:
    ur prob. all laughing at this easy *** question ... but for some reason i cant fig. it out.

    i know how to find even (and odd) numbers in c++ (using the %).

    how the hell do u do it in php tho...

    im trying to alternate the bgcolor of a row in a table (from #CCCCCC to #FFFFFF)

    here is my code..

    if ($row = mysql_fetch_array($result)) {
    $x=0;
    echo "<table width=200 border=1 cellspacing=0 cellpadding=4>";
    do {

    if (($x%2)==0){$color="#FFFFFF";}
    else {$color="#CCCCCC";}
    echo "<tr bgcolor=$color><td>";
    print $row["name"];
    print ("</td><td>");
    print $row["email"];
    print ("</td></tr>");
    $x=$x+1;
    } while($row = mysql_fetch_array($result));
    print ("</table>");
    } else {print "Sorry, no records were found!";

    THX in advance!!
    ryan
    [/quote]


    try this here:

    if (is_int($counter/2)):

    $bgcolor="#eeeeff";

    else:

    $bgcolor="#ffffff";

    endif;

    is_int() test if your line (row) counter an an integer then assigns the bgcolor value accordingly.

Similar Threads

  1. Replies: 2
    Last Post: August 18th, 2004, 10:45 PM
  2. How to see the Memory used by a PHP script?
    By Pardall in forum PHP Development
    Replies: 4
    Last Post: February 13th, 2004, 03:54 PM
  3. Simple find and replace word search for a text file with php?
    By rabid lemming in forum PHP Development
    Replies: 4
    Last Post: February 1st, 2004, 09:37 PM
  4. Replies: 4
    Last Post: January 28th, 2004, 08:29 AM
  5. PHP & Windows 2003
    By jonnymccullagh in forum PHP Development
    Replies: 2
    Last Post: January 20th, 2004, 10:23 AM

IMN logo majestic logo threadwatch logo seochat tools logo