View Single Post
05-12-2008, 09:17 PM
Join Date: May 2008
I always do it like this:
category_id | category_name | category_description | category_parent | category_path
1 | Programming | Programming Tutorials | 0 | 0
2 | PHP | PHP tutorials | 1 | 0 1
4 | PHP Time | PHP Time Tutorials | 2 | 0 1 2
So lets say I want 'programming' subcategories.
select category_id, category_name, category_path from cateogires WHERE category_parent = '1'
and to do the breadcrumbs, I would split 'category_path' into the following format '0', '1' so then I could do
SELECT category_id, category_name, category_path FROM categories WHERE category_id IN ('0', '1').
You will need to keep an array to make sure the rows returned are forced into the correct order for hte breadcrumbs though.
For this, it takes two queries to get the current category and subcategories.
View Public Profile
Send a private message to drewbee
Find More Posts by drewbee