Re: MySQL Results - display issue :S
| From: | David Robley | Date: | Thu, 10 Jul 2003 02:13:43 +0000 |
| Subject: | Re: MySQL Results - display issue :S | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-154662@lists.php.net to get a copy of this message | ||
In article <ANECJPFIMPHFOJPGHDEBAEOLCAAA.brenton@lefevrehs.sa.edu.au>,
brenton@lefevrehs.sa.edu.au says...
> I know im probibly getting irritating to most of you :P but i thought i may
> ask another thing that is on my mind!
>
> I have a sql query bringing back 200 rows for arguments sake, From this i
> would like an answer to 2 issues i have.
>
> 1) I know how to display it row after row going down :P duh of course :P,
> but i have seen sites where it goes across then down across then down ect
> ect like X -> X then next row ect. How is this done??
Easy enough; keep a count of how many records you have processed and use
the modulus operator % to determine where you want to start a new <TR>
> 2) How can i alternate the colours for each row?? row 1 eg light blue and
> the 2nd row dark blue then back to light blue ect ect.
There will be at least n different ways of doing this; one would be to
change the colour using the above test as a trigger. Another is via a
simple ternary operator test:
$bgcolour = ($bgcolour == '#FF0000' ? '#00FF00' : '##FF0000);
In other words if $bgcolour is currently red then make it blue else make
it red.
> Thanks in advance
>
--
Quod subigo farinam