12-07-2007, 08:26 AM
|
#1 (permalink)
|
|
The Wanderer
Join Date: Nov 2007
Location: Denmark
Posts: 21
Thanks: 4
|
Making a navigation list from database
Hi peeps, I hope someone can help me out or point me to a tutorial or code which could help.
The challenge
I want to make an unordered list (and sublists) from product groups in a database.
I think I would need to use some kind of recursive function/looping through this. But I just can't wrap my mind around it. I've searched the Internet quite a bit and found a few directory->list scripts but nothing that I've been able to apply to my needs.
I fetch product groups from database which are returned each in a string like so:
Backup/Tape/LTO
Backup/Tape/RDX
Backup/Tape/Cleaner
Motherboard/Intel
Motherboard/AMD
General solution:
I need to split the string by / and check if the group exists already in an array, and if so, then if the subgroup does not exist, then create it. If the subgroup exists, then check the next element etc. But for me, this gets complex fast.
In the meantime...
I'm going to read some articles I found on recursion and traversing arrays etc.
Thank you everybody.
|
|
|