JStefan Posted May 2, 2010 Share Posted May 2, 2010 Hi all, I am writting a page where a table should generated with records from a MySql database. The database has 2 tables, 'categories' and 'items' and the 'items' table have a record set which link the specific item to one of the categories. I need help with the php code which will generate the table with a column for each category from the 'category' table and under the category row will generate a new row in which will be included the records from the 'items' table linked to the specific category record Thank you in advance for you time and help. Cheers, Julian Link to comment https://forums.phpfreaks.com/topic/200414-php-generated-table-with-records-from-mysql-table/ Share on other sites More sharing options...
Ken2k7 Posted May 2, 2010 Share Posted May 2, 2010 I don't understand a thing you said. Link to comment https://forums.phpfreaks.com/topic/200414-php-generated-table-with-records-from-mysql-table/#findComment-1051749 Share on other sites More sharing options...
JStefan Posted May 2, 2010 Author Share Posted May 2, 2010 Hi all, I try to make myself more clear I need help with the php code which will generate a table based on a MySql Database. Lets say I have 2 tables in my database, category and items. Under category I have fruits and veggies records and in items i have bananas and apples (both records have a field fruits) and carrots and potatoes (both records have a field veggies) My php code should generate a page with a table with 2 columns and 3 rows like follows: Fruits Vegiess First row contain the records from category Bananas Carrots This and next row contain the records from items Apples Potatoes If I add a new record in category table in MySql database a new column will be generated in the table in my page. If I add a new record in items table in MySql database a new row will be generated in my page as long as the record contain a field which link it to a valid record from category table in MySql database and so on.... Thank you in advance for you time and help. Cheers, Julian Link to comment https://forums.phpfreaks.com/topic/200414-php-generated-table-with-records-from-mysql-table/#findComment-1051772 Share on other sites More sharing options...
Ken2k7 Posted May 2, 2010 Share Posted May 2, 2010 So basically, you just want to display the data of your database table on your web page? Link to comment https://forums.phpfreaks.com/topic/200414-php-generated-table-with-records-from-mysql-table/#findComment-1051780 Share on other sites More sharing options...
JStefan Posted May 2, 2010 Author Share Posted May 2, 2010 Yes thanks, formatted in a table with as many columns as how many records found in category table. Julian Link to comment https://forums.phpfreaks.com/topic/200414-php-generated-table-with-records-from-mysql-table/#findComment-1051783 Share on other sites More sharing options...
Ken2k7 Posted May 2, 2010 Share Posted May 2, 2010 Okay, so you have 2 tables. Are they related in any way? Fruits Vegiess First row contain the records from category Bananas Carrots This and next row contain the records from items Apples Potatoes That's confusing. Can you display the data as it appears in phpMyAdmin or something? Link to comment https://forums.phpfreaks.com/topic/200414-php-generated-table-with-records-from-mysql-table/#findComment-1051793 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.