Re: SQL Result Set -> HTML Table Fragment (but Simple)
| From: | tedd | Date: | Tue, 25 Jul 2006 14:55:20 +0000 |
| Subject: | Re: SQL Result Set -> HTML Table Fragment (but Simple) | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-239770@lists.php.net to get a copy of this message | ||
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. hth's tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com