[thelist] simple! PHP data display

Andrew Maynes andrew at humanbehaviour.co.uk
Thu Aug 22 10:46:01 CDT 2002


Unfortunately neither of these two snippets of code work

the first produces the same colour for all the rows displayed and the sceond
just produces 1 row and a black screen.

Andrew

Your solution is fine, but FWIW:

$rowcount++;
if ($rowcount % 2 == 0) {
  print ("<tr bgcolor=\"#FFFFCC\">\n");
} else {
  print ("<tr>\n");
}

If you don't like big sprawling if() statements, or you're after enhanced
job security, you can squash all of the above into one line:

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
--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/02

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/02




More information about the thelist mailing list