Skip to site navigation (Press enter)

[PHP-DB] Re: SELECT & html

El Bekko Mon, 05 Dec 2005 09:11:14 -0800

Ron Piggott (PHP) wrote:
I would like to display the contents of my table with the first row
being grey in background and the next row being white and the third row
being grey, fourth being white, etc.  I am not sure how to do this.

Well, that's pretty easy to do actually :P
You have your while() statement to execute your displaying part. In there, you add some if()'s

I'll use an example for 20 posts. An example:

$array1 = array(1,3,5,7,9,11,13,15,17,19)

<?php
while($i < $totalrows)
{
$j = $i - 1;
if($i == array1[$j])
{
--some code--
echo "<tb class=\"grey\">all the rest</tb>";
}
else
{
--some code--
echo "<tb class=\"white\">all the rest</tb>";
}
--more code--
}
?>

This is a really easy way to do it, and I guess it works :)

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

  • Previous message
  • View by thread
  • View by date
  • Next message

Reply via email to

The Mail Archive
  • The Mail Archive home
  • php-db - all messages
  • php-db - about the list
  • Expand
  • Previous message
  • Next message
  • The Mail Archive home
  • Add your mailing list
  • FAQ
  • Support
  • Privacy
  • 88.76.14828.B6474934@pb1.pair.com