Jump to content

table `categories`


phpsycho

Recommended Posts

What would be the best way to do categories and multiple sub categories for a eCommerce website?

For example there could be...

Website templates => Flash => Portal => Music

Computer hardware => Gadgets => USB => Fun

Scripts => PHP => eCommerce => Simple

Scripts => Perl => Search engine => Simple

 

So something like that.. how should the database structure look?

 

Also say I have a table called 'products' and a column called 'cat'.. if the best idea would be to create `categories` `sub1_cat` `sub2_cat` etc for tables then should I put each id of the categories into the column 'cat' and separate by comma? Then like explode that column when I need to grab each category or whatever?

I dunno... lol very confusing, I just can't wrap my head around it.

Link to comment
https://forums.phpfreaks.com/topic/247229-table-categories/
Share on other sites

Like I said..

I could just create like 5 tables (subcat1,subcat2,subcat3, etc) and then just add each id from each of those tables to the product table column `cat` and when needed I could explode or something.. dunno how I'd pull specific products from each sub category though using a sql query.

Theres gotta be a better way... I just can't seem to find it.

Link to comment
https://forums.phpfreaks.com/topic/247229-table-categories/#findComment-1269736
Share on other sites

Could you give an example?

Sorry lol I feel dumb, but I don't really know what you mean by a nested set.

 

hmmm any other ideas then maybe? I'm looking for the most simple, but works perfectly. I suppose I could use a pain in the ass method if I had to, but yeah.. rather not lol.

Link to comment
https://forums.phpfreaks.com/topic/247229-table-categories/#findComment-1269749
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.