Forum Moderators: coopster

Message Too Old, No Replies

2d Table

         

protocode

8:23 pm on Feb 12, 2010 (gmt 0)

10+ Year Member



I have pulled information from my database. I need to display that information in a table with two identifiers, a row and column. Example

+-------+-------+-------+
| | 2009 | 2010 |
+-------+-------+-------+
| Jan. |(count)|(count)|
+-------+-------+-------+
| Feb. |(count)|(count)|
+-------+-------+-------+
I can query the information correctly, but displaying it is way off.

Thanks for any hints or suggestions in advance.

protocode

8:24 pm on Feb 12, 2010 (gmt 0)

10+ Year Member



I messed up, I meant for this to be in PHP, sorry.

physics

11:29 pm on Feb 12, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld.com protocode!

Something like this should do the trick:

1) Find out string length of longest entry in each column
(for example use

SELECT MAX( LENGTH( column1 ) ), MAX( LENGTH( column2 ) ) FROM `tablename`;

Save this in an array
For each column, check if the column name itself is longer than any of these and if so update the max length array with that number

2) * When printing each row/column use the 'str_pad' function [php.net...] to print each field with the correct number of spaces

That should get you started anyway :)