> -----Original Message-----
> From: Patrick Lebon [mailto:[EMAIL PROTECTED]]
> Sent: 26 September 2002 16:20
> 
> This is how im currently doing it...
> 
>  $rowNum = 0;
>  while ( $row = mysql_fetch_array($result) )
>  {
>  $rowNum++;
>  if ($rowNum % 2) { $bgCol = "#EADBC6"; } else { $bgCol = "#EFE1CE"; }
> echo "......";
> }

Looks like a good 'un to me, although I wonder why you're incrementing
$rowNum and then doing a separate access to it, when the ++ operator is
designed precisely to avoid the need for this; the following is identical in
functionality to the above:

  $rowNum = 0;
  while ( $row = mysql_fetch_array($result) )
  {
    if ($rowNum++ % 2) { $bgCol = "#EADBC6"; } else { $bgCol = "#EFE1CE"; }
    echo "......";
  }

And, having got this far, I'd probably then go on to rewrite the if line
using the ?: operator instead:

    $bgCol = ($rowNum++ % 2) ? "#EADBC6" : "#EFE1CE";

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

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

Reply via email to