[thelist] simple! PHP data display
R.Livsey
R.Livsey at cache-22.co.uk
Thu Aug 22 09:49:01 CDT 2002
> Hi Jay,
>
> > if ($rowcount == 1) {
> > print("<tr bgcolor=\"#FFFFCC\">\n");
> > } elseif ($rowcount <> 1) {
> > print("<tr>\n");
> > $rowcount = 0;
> > }
> >
> $rowcount++;
> if ($rowcount % 2 == 0) {
> print ("<tr bgcolor=\"#FFFFCC\">\n");
> } else {
> print ("<tr>\n");
> }
>
> or
>
> echo "<tr". ((++$rowcount % 2 == 0) ? " bgcolor=\"#FFFFCC\">"
> : ">"). "\n";
>
> or, if you want to specify a bgcolor for both rows:
>
> echo "<tr bgcolor=\"#". ((++$rowcount % 2 == 0) ? "FFFFCC" :
> "CCFFFF"). ">\n";
>
> Cheers
> Jon
Hi.
I occasionally use something along the lines of:
// --- outside the loop --- //
$colour1 = "#EEEEEE";
$colour2 = "#FFFFFF";
$currColour = $colour1;
// --- inside the loop --- //
// toggle colours
$currColour==$colour1 ? $currColour=$colour2 : $currColour=$colour1;
echo "<td bgcolor=\"$currColour\">\n";
etc...
Has the advantage of specifying the colours outside of the loop so you
can change them globally if you wanted to.
R.Livsey
Incutio Web Developer
[ PHP | Perl | mySQL | Java ]
w : cache-22.co.uk
e : R.Livsey at cache-22.co.uk
/ Richard at incutio.com
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.380 / Virus Database: 213 - Release Date: 24/07/2002
More information about the thelist
mailing list