TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 12-07-2007, 08:26 AM   #1 (permalink)
The Wanderer
 
victorius's Avatar
 
Join Date: Nov 2007
Location: Denmark
Posts: 21
Thanks: 4
victorius is on a distinguished road
Default 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.
Send a message via MSN to victorius
victorius is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 12:07 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design