Page 1 of 1

PHP displaying MYSql data formated in table

Posted: Sun May 02, 2010 1:56 pm
by JStefan
Hi all,
I need a little help writing the php code for a page which will display a table with as many columns as how many records found in a MySql database table and as many rows as how many rows are found on a different MYSql table. The two tables are related so lets say if I have a fruit record in first table the apples and bananas will display under this record. So basically the first row will extract the captions from first MySql table and following rows will display the actual records from second MySql table.
Thanks in advance for your help.
Julian

Re: PHP displaying MYSql data formated in table

Posted: Mon May 03, 2010 7:57 pm
by mecha_godzilla
Trying to retrieve the column names is a bit more involved than a normal query, so I suggest you look at the following address for some example code as a starting point:

http://uk2.php.net/manual/en/function.m ... .php#25664

I tried this and it seemed to work - it basically generates a table view exactly as it looks when you 'browse' a table in phpMyAdmin. This doesn't quite solve you're problem but it shouldn't take too much effort to extrapolate what this script does to your 'two table' model.

If you need any further help just say so.

HTH,

Mecha Godzilla