Page 1 of 1

performing queries

Posted: Mon Aug 15, 2005 6:14 am
by srinivaasan
Hello,

Iam srinivaasan, I am a newbie to query. I have a small problem to solve. First of I have a table named [MENUS]
with its fields as (menu_id, menu_parent, menu_title, menu_order).

menu_id : is an unique ID and primary key
menu_parent: is an ID of the parent menu.
menu_title: is the name of the menu.
menu_order: is the order in which the menu is displayed.

For example: I have menus in my site saying. "HOME PROGRAMMING GRAPHICS AUTHORING" etc

Assume that the above menus have the submenus like

for PROGRAMMING -> VISUAL BASIC, PHP, ASP, etc.,

and for GRAPHICS -> PHOTOSHOP, FLASH, etc,.

AUTHORING -> PRIEMERE, etc.,

Can anyone pls help me to solve the query by extracting these menus and arrange it on my site dynamically using a single query from the given table.

Thanks regards

Srinivaasan.



feyd | help others help you, use a better thread subject instead of "[HELP] Pls, help!"

Posted: Mon Aug 15, 2005 7:11 am
by feyd
read the useful posts thread which is linked to in my signature. You'll find such a solution.

Posted: Mon Aug 15, 2005 7:11 am
by shiznatix
i would just take a query that selects the whole table then just put it into a multi demensional array and start sorting it with a recursive function.

Posted: Mon Aug 15, 2005 6:49 pm
by srinivaasan
Thanks a lot! Using a recursive it is working well.

Posted: Mon Aug 15, 2005 8:35 pm
by Ambush Commander
You may want to try a modified preorder tree traversal algorithm if you want your program to run faster: PHP is not designed to be a recursive language like Lisp.

Posted: Tue Aug 16, 2005 4:33 am
by srinivaasan
Thank you very much for the tutorial "Preorder tree travarsel alg.". Now I can get around with any hieriarchy.
Thanks again for your great support.