Read your mail to fast:

Change, "$posts_info=0;", into: "$posts_info++;", then you
should get alternate colors.

 

-----Original Message-----
From: Anthony Ritter
To: [EMAIL PROTECTED]
Sent: 2003-08-20 02:36
Subject: [PHP-WIN] output a table

Hi...
I'm trying to output a table with alternate background color rows.

The following snippet outputs a table after connecting to a mySQL
database
with posts but all of the rows have the same bgcolor.

Any help with the syntax will be greatly appreciated.
Thank you.
Tony Ritter
........................................
<?

<table width=100% cellpadding=3 cellspacing=1 border=1>
   <tr>
   <th bgcolor=\"#497fbf\"><font color=\"#ffffff\">AUTHOR</font>
   </th>
   <th bgcolor=\"#497fbf\"><font color=\"#ffffff\">POST</font></th>
   </tr>";

   while ($posts_info = mysql_fetch_array($get_posts_res)) {
       $post_id = $posts_info['post_id'];
       $post_text = nl2br(stripslashes($posts_info['post_text']));
       $post_create_time = $posts_info['fmt_post_create_time'];
       $post_owner = stripslashes($posts_info['post_owner']);

       $color1 = "#CCFFCC";
       $color2 = "#BFD8BC";
       $posts_info = 0;
       $row_color = ($posts_info % 2) ? $color1 : $color2;

       //add to display
       $display_block .= "
       <tr>
       <td width=35% valign=top
bgcolor=\"$row_color\"><p>$post_owner<br>[$post_create_time]</td>
       <td width=65% valign=top
bgcolor=\"$row_color\"><p>$post_text<br><br>
       <a href=\"replytopost.php?post_id=$post_id\"><strong>REPLY TO
POST</strong></a></td>

       </tr>";

   }

  //close up the table
  $display_block .= "</table>";
?>




-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to