Hassang
05-09-2010, 04:43 PM
1) Script Title: Drill Down Menu
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/drilldownmenu.htm
3) Describe problem:
I want to have the Drill Down menu gets its elements from a database, I am using php and MySQL and the table (categories) looks like this :
---------------------------------------
--cat_Id---cat_Name---cat_Parent_Id--
---------------------------------------
----1-------Mecanic--------0----------
----2--------Maths---------0----------
----3--------Sports---------0----------
----4---------Moto---------1----------
----5----------Car----------1----------
----6-------Geometry--------2---------
----7-------Algebra---------2----------
----8-------Football--------3----------
----9-------Volleyball--------3---------
---10-------HandBall--------3----------
---------------------------------------
I understand the logic of the hierarchy but I can't figure out how I can extract these information in a way I could put it inside the Drill Down Menu !
I found the recursive method (with LEFT JOINs) and the nested method which I barely understood and again I couldn't apply it to the Drill Down Menu.
Normally, each parent should be inside a
<li> tag and if it has childs, they should be inside the same
<li> but also inside an
<ul>tag, which I believe that's Drill Down Menu structure !
Some people says I should do a "query inside a loop", how is that going to be with Drill Down Menu Structure ?
I would be more than gratefull if you could give me the extact syntax of the loop or another workaround if there is.
Thanks a lot for your hard work,
Hassan
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/drilldownmenu.htm
3) Describe problem:
I want to have the Drill Down menu gets its elements from a database, I am using php and MySQL and the table (categories) looks like this :
---------------------------------------
--cat_Id---cat_Name---cat_Parent_Id--
---------------------------------------
----1-------Mecanic--------0----------
----2--------Maths---------0----------
----3--------Sports---------0----------
----4---------Moto---------1----------
----5----------Car----------1----------
----6-------Geometry--------2---------
----7-------Algebra---------2----------
----8-------Football--------3----------
----9-------Volleyball--------3---------
---10-------HandBall--------3----------
---------------------------------------
I understand the logic of the hierarchy but I can't figure out how I can extract these information in a way I could put it inside the Drill Down Menu !
I found the recursive method (with LEFT JOINs) and the nested method which I barely understood and again I couldn't apply it to the Drill Down Menu.
Normally, each parent should be inside a
<li> tag and if it has childs, they should be inside the same
<li> but also inside an
<ul>tag, which I believe that's Drill Down Menu structure !
Some people says I should do a "query inside a loop", how is that going to be with Drill Down Menu Structure ?
I would be more than gratefull if you could give me the extact syntax of the loop or another workaround if there is.
Thanks a lot for your hard work,
Hassan