Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PHP/MySQL Question

  • 04-01-2005 11:58am
    #1
    Registered Users, Registered Users 2 Posts: 20


    Hi,

    I'm working on a simple proprietary shopping basket system written in PHP with a MySQL back end. My question is: what is the best way to implement subcategories?

    At the moment, I have a database of products which all get listed on the index page (paginated) but I want to organise them into categories and subcategories of varying depths. The index page should list all top-level categories. When the user clicks on one of these, the index page displays the subcategories (if any) or else all the products in that category. And so on.

    Can anyone point me in the right direction on how to implement this? What database fields should I add to the products DB?

    A model of what I want would be Meadows and Byrne.

    I hope this is clear. Can anyone help?

    Thanks,
    Bill.


Comments

  • Registered Users, Registered Users 2 Posts: 7,740 ✭✭✭mneylon


    Have you looked at how OSCommerce handles it?


  • Registered Users, Registered Users 2 Posts: 20 bos


    blacknight wrote:
    Have you looked at how OSCommerce handles it?
    No, but I will now. Does anybody know of any tutorials/basic implementations that I could take a look at?


  • Registered Users, Registered Users 2 Posts: 7,740 ✭✭✭mneylon


    I'd always recommend having a look at Hotscripts.com - there's a lot of tutorials and scripts over there.


  • Registered Users, Registered Users 2 Posts: 1,562 ✭✭✭Snaga




  • Registered Users, Registered Users 2 Posts: 912 ✭✭✭chakotha


    I haven't yet had to go to subcategories but if you have the tables products, categories and products_categories could you add also a categories_categories table?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,452 ✭✭✭tomED


    It depends on how complex you want your overall system to be. The simplest form I ever used is like this:

    A categories table, with a field called "SubOf" - every category, including subcategoires are stored in this table, the SubOf filed will refer to the uppermost categoryID that a category belongs to.

    Example

    [HTML]ID1. Category 1
    > ID2. Sub1 (Subof = ID1)
    > ID3. Sub2 (Subof = ID1)
    > ID4. Subof2-1 (SubOf = ID3)

    Etc....[/HTML]

    Hope that's not confusing.

    You can always add another table that stores the ID's of each category and the category they are a subof, but that just seems like too much work coding wise! :)


Advertisement