Re: Anyway of knowing whether a integer is odd or even
| From: | _lallous | Date: | Tue, 09 Oct 2001 14:48:38 +0000 |
| Subject: | Re: Anyway of knowing whether a integer is odd or even | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-70469@lists.php.net to get a copy of this message | ||
sometimes you don't want to know whether odd or even to do what you're
asking for, therefore, consider the XOR example:
$colors = array("red", "green");
$start = 0;
while ($row = mysql_fetch_array($result))
{
echo "<td bgcolor='{$colors[$start]}'>{$row[firstnamename]}</td>";
$start ^= 1; // 1 xor 1 = 0, 0 xor 1 = 1, etc....
}
etc.....
"Sam" <Sam@dragoman.co.uk> wrote in message
news:478EB6C82CC2D4119AF300B0D07963F4115C85@NTSERVER01...
> Hi all,
>
> I have a query which returns X amount of rows.
> I would like to display even rows one colour and odd rows a different
> colour.
> Is there a way to do this?
>
> Thanks in advance,
>
> Sam Rose
>
> p.s. Also I'm only on the digest, so if you could reply directly to me as
> well, that would be a bonus.
>