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 10-20-2012, 02:47 AM   #1 (permalink)
The Visitor
Newcomer 
 
Join Date: Oct 2012
Posts: 2
Thanks: 0
soduno is on a distinguished road
Default recursive function with collapsible menu

Hey Guys.

Ma' brain is stuck.
I'm currently working on customizing a menu. Got the following code, but wan't the list
to be collapsible without using any Javascript/Jquery, only pure PHP.
Do you guys have any idea how to do that?

PHP Code:
function display_children($parent$level) {
    
$result mysql_query("SELECT a.id, a.label, a.link, Deriv1.Count FROM `menu` a  LEFT OUTER JOIN (SELECT parent, COUNT(*) AS Count FROM `menu` GROUP BY parent) Deriv1 ON a.id = Deriv1.parent WHERE a.parent=" $parent);
    echo 
"<ul>";
    while (
$row mysql_fetch_assoc($result)) {
        if (
$row['Count'] > 0) {
            echo 
"<li><a href='" $row['link'] . "'>" $row['label'] . "</a>";
            
display_children($row['id'], $level 1);
            echo 
"</li>";
        } elseif (
$row['Count']==0) {
            echo 
"<li><a href='" $row['link'] . "'>" $row['label'] . "</a></li>";
        } else;
    }
    echo 
"</ul>";
}

display_children(01); 
All help will be appreciated!
//Simon
soduno 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a gallery class Tanax Advanced PHP Programming 25 02-19-2013 04:25 AM
Next class project? allworknoplay The Lounge 6 04-18-2009 08:33 PM
Fix recursive function on a directory listing Peuplarchie General 1 04-13-2009 03:04 AM
[Tutorial] How to organize your classes | Part 1 Tanax Advanced PHP Programming 10 03-01-2009 10:08 PM
Menu using 2 js functions. Sam Granger Javascript, AJAX, E4X 0 11-15-2007 01:26 PM


All times are GMT. The time now is 12:31 PM.

 
     

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