User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,611 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,441 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 868 | Replies: 1 | Solved
Reply
Join Date: Jan 2007
Posts: 2
Reputation: masterkain is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
masterkain masterkain is offline Offline
Newbie Poster

Help help with recursion, for experts

  #1  
Jan 22nd, 2007
hi there,
I need a hand with recursion in php.

I've this array:

[Forum] => Array
      (
          [0] => Array
              (
                  [id] => 12
                  [forum_category_id] => 2
                  [parent_id] => 0
                  [forum_post_id] => 0
                  [name] => PHP
                  [description] => 
                  [url] => php
                  [topics] => 0
                  [posts] => 0
                  [order] => 0
                  [topics_per_page] => 20
                  [ForumLastPost] => 
              )

          [1] => Array
              (
                  [id] => 15
                  [forum_category_id] => 2
                  [parent_id] => 0
                  [forum_post_id] => 0
                  [name] => ASP.NET
                  [description] => 
                  [url] => asp_net
                  [topics] => 0
                  [posts] => 0
                  [order] => 0
                  [topics_per_page] => 20
                  [ForumLastPost] => 
              )

                    [...]

          [7] => Array
              (
                  [id] => 21
                  [forum_category_id] => 2
                  [parent_id] => 0
                  [forum_post_id] => 0
                  [name] => Databases
                  [description] => 
                  [url] => databases
                  [topics] => 0
                  [posts] => 0
                  [order] => 0
                  [topics_per_page] => 20
                  [ForumLastPost] => 
              )

          [8] => Array
              (
                  [id] => 22
                  [forum_category_id] => 2
                  [parent_id] => 21
                  [forum_post_id] => 0
                  [name] => MySQL
                  [description] => 
                  [url] => mysql
                  [topics] => 0
                  [posts] => 0
                  [order] => 0
                  [topics_per_page] => 20
                  [ForumLastPost] => 
              )

          [9] => Array
              (
                  [id] => 23
                  [forum_category_id] => 2
                  [parent_id] => 21
                  [forum_post_id] => 0
                  [name] => SQLite
                  [description] => 
                  [url] => ms_sql
                  [topics] => 0
                  [posts] => 0
                  [order] => 1
                  [topics_per_page] => 20
                  [ForumLastPost] => 
              )

          [10] => Array
              (
                  [id] => 24
                  [forum_category_id] => 2
                  [parent_id] => 23
                  [forum_post_id] => 0
                  [name] => 2000
                  [description] => SQL Server 2000
                  [url] => sql_server_2000
                  [topics] => 0
                  [posts] => 0
                  [order] => 1
                  [topics_per_page] => 20
                  [ForumLastPost] => 
              )

      )

I need to get a front page with every of those entries, but the ones that have no parent_id set or 0 need to be in <td> in a table, when the cycle encounters a child (parent_id > 0) need to break the cycle, make an h2 with this parent and then again make a table with their children, when this encounter another parent_id > 0 h2 and then table again, so I can have infinite n-tree recursion.

can somebody please help me out with a parser that generates html like this?
thanks
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2007
Posts: 2
Reputation: masterkain is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
masterkain masterkain is offline Offline
Newbie Poster

Re: help with recursion, for experts

  #2  
Jan 22nd, 2007
solved, thanks anyway.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 7:18 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC