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
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-18-2012, 11:14 AM   #1 (permalink)
The Visitor
Newcomer 
 
Join Date: Oct 2012
Posts: 2
Thanks: 0
soduno is on a distinguished road
Default Multilevel php menu

Hello.

I'm trying to make an multilevel menu. But the way i wan't it to work seems to be a bit complicated for me. I wan't the menu to work like this one(left menu): http://www.proconsult.dk/. The page must reload every time a menu has been clicked, because i wan't a new page to open (newest offers related to the clicked category).

So far i managed to get a non collapsable menu script:
PHP Code:
<?php 
// get all menuitems with 1 query 
$result mysql_query("SELECT cat_id, cat_parent, cat_name FROM categories ORDER BY cat_id, cat_name ");

// prepare special array with parent-child relations 
$menuData = array( 
    
'items' => array(), 
    
'parents' => array() 
); 

while (
$menuItem mysql_fetch_assoc($result)) 

    
$menuData['items'][$menuItem['cat_id']] = $menuItem
    
$menuData['parents'][$menuItem['cat_parent']][] = $menuItem['cat_id']; 


// menu builder function, parentId 0 is the root 
function buildMenu($parentId$menuData

    
$html ''

    if (isset(
$menuData['parents'][$parentId])) 
    { 
        
$html '<ul>'
        foreach (
$menuData['parents'][$parentId] as $itemId
        { 
            
$html .= '<li>' $menuData['items'][$itemId]['cat_name']; 

            
// find childitems recursively 
            
$html .= buildMenu($itemId$menuData); 

            
$html .= '</li>'
        } 
        
$html .= '</ul>'
    } 

    return 
$html


// output the menu 
echo buildMenu(0$menuData);
?>
Just so you know. I don't want to use any Jquery, the menu must be pure php, if possible
Thank you in advance.

Regards, Simon
soduno is offline  
Reply With Quote
Old 11-13-2012, 11:37 AM   #2 (permalink)
The Addict
 
Join Date: Nov 2012
Posts: 331
Thanks: 0
shui1880 is on a distinguished road
Default

If you are a music enthusiast longing to listen to your favorite music for extended periods of time, Monster headphones fit the bill perfectly. They have been designed to ensure a thrilling music experience for extended periods without causing discomfort or pain to the user. An interesting feature of Dr Dre Headphones the Monster Beats is that you don need to dig into your pocket to pause or press mute. A quick tap is what it takes to do the needful. You can choose from a variety of eye-catching accessories to complement dr dre beats these headphones. Browse the web to navigate an exotic range of stunning accessories online. They are http://www.drdreheadphones-sale.net available at astonishingly competitive prices.
shui1880 is offline  
Reply With Quote
Reply



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
PHP Beginner Guide #1 Hershey Absolute Beginners 1 11-07-2011 10:42 PM
php mysql menu nandananushil1 Advanced PHP Programming 1 11-28-2010 05:09 AM
php drop down menu Shiag Absolute Beginners 2 07-23-2009 10:08 AM
10 PHP Myths Dispelled Wildhoney General 9 06-15-2009 06:55 AM
PHP Compressor Kalle Script Giveaway 8 05-28-2008 12:14 AM


All times are GMT. The time now is 12:50 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