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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux