I don't know how to tackle this problem!

I am currently working on a project. Simply put it’s a mix between ebay and gumtree. I want users to be able to post listings of different categories, and each category will need different data stored about each listing.

How do I go about structuring this? I am currently using a main listings table in the database and further separate tables (that are linked by foreign ID) to the main table to contain the other fields.

When a user wants to create a listing however, I initially have a dropdown so a category can be chosen, but after that it all becomes a nightmare, since the add listing form will be different for each category, do I just a separate form for each and a separate PHP form handler or is there a more integrated and efficient way to go about it?

you want us to figure out for you what data you want to store?

that’s a bit unrealistic, i’d say

how about you try to create the structure, put all the columns in that you need to store, work on your one-to-many relationships, and then show us what you got

as it stands now, your question is far too nebulous

I want to know how to dynamically output the correct fields of the form for each category. Each category will have different data stored as well as similar data, so each add and edit form will be different. I was asking if there was a more efficient method than just having a separate form and separate PHP handler file for each form.

I actually posted this in the PHP forum but it seems to have been moved

actually you cross-posted into both forums, and a moderator made a decision to close the php thread and leave this one open

now you will have to ask the moderators (via the little red flag on the left) to move this thread over

see the trouble you cause yourself when you cross-post?


If you do not know the columns an entity will have EAV is what your after. Though, its probably best to stay away and get a better understanding of the data you need to work with as already recommended. Meta data really goes against the primary benefit of a relational database. There are other databases that are more for storing meta data, a relational database really isn’t it. Can it be done, yes. In fact wordpress, drupal,magento and I’m sure countless other systems do it. is it a gigantic, convoluted mess – yes. To put things in perspective EAV is a SQL anti-pattern. Bets to udnerstand the data your working with and create a concrete schema based on it.