Re: SQL Result Set -> HTML Table Fragment (but Simple)

From: Date: Tue, 25 Jul 2006 21:22:34 +0000
Subject: Re: SQL Result Set -> HTML Table Fragment (but Simple)
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-239783@lists.php.net to get a copy of this message
At 10:55 AM -0400 7/25/06, tedd wrote:
At 12:46 AM -0400 7/25/06, Michael B Allen wrote:
Ok, I've been tinkering a little. This isn't "simple" but it's not a lot of code either.
Granted, and no offense, it isn't simple the way you've attempted it. You simply have three columns with these conditions: 1. Is gray if odd; 2. Is a time stamp 3. Is green if > 1000. After placing your data in arrays via the dB, start a table and loop pulling variables ($i, $timestamp[], $value[]) from the arrays and display them like so: <td id="<?php if ($i & 1) echo "grey"; ?>"> <?php echo($i); ?> </td> <td> <?php echo date("M j, Y g:i a", $timestamp[$i]); ?> </td> <td id="<?php if ($value[$i]>1000) echo "green"; ?>"> <?php echo($value[$i]); ?> </td> Place the colors "gray" and "green" in a css, where they should be. I have not tested this code, so it may have errors, but the technique should work.
Just noticed -- slight modification. The: <td id=" should be: <td class=". The "id" divs can only be used once per page whereas "class" divs can be used as many times as needed. tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com

« previous php.general (#239783) next »