Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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