View Single Post
09-23-2011, 12:06 PM
#1
neojiphre is offline neojiphre
Status: I'm new around here
Join date: Sep 2011
Location:
Expertise:
Software:
 
Posts: 7
iTrader: 0 / 0%
 

neojiphre is on a distinguished road

  Old  Lookup in same table with PHP

I want to create a breadcrumb navigation on my pages, but I have very little knowledge of PHP and MySQL. Here is my situation. I have a table of categories, with a row named 'cat_parent_id' that tells ID of the parent category (there are first level AND second level categories). If the category has no parent ID, it's 'cat_parent_id' is set to 0, meaning that it's a first level category.



So, I would like some help on how to code the PHP for my breadcrumb navigation. I have a page named index.php and whenever I navigate to a category page, the URL becomes 'index.php?c=18' (for category with an ID of 18). I want to use this to create an if statement, that checks if category has parent_id of 0 to only display:

Home >> Category_Name

for my breadcrumbs. If the parent_id is greater than 0, then lookup the name of the category with the ID in the database, then append the name of the current category, eg:

Home >> Parent_Category_Name >> Current_Category_Name

Please some help guys