Jump to content

PHP / SQL Menu list with subcast


drew7721

Recommended Posts

Hi! I'm looking to make a dropdown menu based on a db table

 

SQL table: Categories

cat_id = INT auto_increase PRIMARY

cat_name = VARCHAR (80)

parent_id = INT NOT NULL default 0

 

-------------

 

Now I want to populate this table with categories and sub categories.

Main categories get 0 as parent_id

 

Now I want to add a sub cat so I'll give it a parent_id = 1 for it's parent cat to be the cat with cat_id =1

 

But I want to make a dropdown menu on site that will show

 

PARENT CAT 1

---subcat 1.1

---subcat 1.2

PARENT CAT 2

---subcat 2.1

---subcat 2.2

PARENT CAT 3

PARENT CAT 4

---subcat 4.1

 

ETC!

 

how do I do this? I've been killing myself over this? can someone help please???

Link to comment
https://forums.phpfreaks.com/topic/181040-php-sql-menu-list-with-subcast/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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