Say my category table looks like this:
ID | CatName | ParentID
Then another table has all of the product-to-category associations, like this:
ID | ProductID | CatID
A third table has an ID field for each product, plus the product's information.
And to display a certain category, the query looks something like:
SELECT * FROM products AS p, associations AS a
WHERE p.ID = a.ProductID AND a.CatID = '$id'
Naturally, I wouldn't be selecting everything (*) from these two tables.
Now, how would I display at the top of the page the category hierarchy?
Such as "Category1 > SubCategory1 > CurrentCategory"
This is where I'm stumped at finding the most efficient solution...
Also, PART 2 of my question:
How can I output an entire category table of names into, say, a drop-down list?
For instance, inside this list would be printed:
Autos
Autos > Acura
Autos > BMW
Autos > Jeep
Autos > Jeep > Grand Cherokee
Autos > Jeep > Grand Cherokee > Laredo
Autos > Jeep > Grand Cherokee > Limited