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