Jump to content

Php generated table with records from MySql table


JStefan

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.