I need some help with an algorithm that I'm writing to build a categories 
array, based on the mysql table.

the table goes by:
id_category, name_category, parent_category

and with a simple query, with a group by and after doing a little for(;;) 
processing, I get the following array..

categ   | parent        | num_childs
null       1               1
null       4               0
1          5               2
5          6               0
5          7               0

well... I have a function called CatName($id) that returns me the name of 
that giving its ID... so, I want from that array build a new array like this:

[0]["id"] = 1
[0]["name"] = Electronics
[1]["id"] = 5
[1]["name"] = Electronics/Palm
[2]["id"] = 6
[2]["name"] = Electronis/Palm/WindowsCE
[3]["id"] = 7
[3]["name"] = Electronis/Palm/PalmOS
[3]["id"] = 4
[3]["name"] = Food

preety nasty hun? I know its something recursive... but I can't figure out 
how to "walk" trough the array to get this kind of output...

any help will be welcome..


PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to