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-15-2009, 07:09 AM   #1 (permalink)
The Wanderer
 
mombunheng's Avatar
 
Join Date: Oct 2009
Posts: 5
Thanks: 0
mombunheng is on a distinguished road
Default PHP & MySQL Verticle Collapse menus

Hi everything,

I am trying to get the PHP & MySQL Verticle collapse menus work on my website with following concept:

- menu 1
- menu 2
- menu 3
- menu 3

If visitor click on menu 1 it will direct to that page of menu 1 and then list sub menus as the following concept:

- menu 1
. Testing Menus 1
. Testing Menus 2
. Testing Menus 3
. Testing Menus 4
- menu 2
- menu 3
- menu 3

Any body had experience with that please kindly let me know.

Regards,
Bunheng.
mombunheng is offline  
Reply With Quote
Old 10-15-2009, 09:00 AM   #2 (permalink)
The Wanderer
 
gamer13's Avatar
 
Join Date: Sep 2009
Posts: 15
Thanks: 4
gamer13 is on a distinguished road
Default

At least I can give you the database table:

menu:
=====
id INT AUTO_INCREMENT PRIMARY KEY
name VARCHAR(255)
link VARCHAR(255)
parent_id INT DEFAULT '0'

And you fill it with:
1 | menu 1 | view.php?p=1 | 0
2 | menu 2 | view.php?p=2 | 0
3 | menu 3 | view.php?p=3 | 0
4 | menu 4 | view.php?p=4 | 0
5 | Testing menus 1 | view.php?p=1&action=1 | 1
6 | Testing menus 2 | view.php?p=1&action=2 | 1
7 | Testing menus 3 | view.php?p=1&action=3 | 1
8 | Testing menus 4 | view.php?p=1&action=4 | 1

You can also keep track of the 'order' in which every item has to be.
gamer13 is offline  
Reply With Quote
Old 10-15-2009, 02:04 PM   #3 (permalink)
The Wanderer
 
mombunheng's Avatar
 
Join Date: Oct 2009
Posts: 5
Thanks: 0
mombunheng is on a distinguished road
Default

Any one can guide to how to select categories and its subcategories techniques.
mombunheng is offline  
Reply With Quote
Old 10-27-2009, 04:12 PM   #4 (permalink)
The Visitor
 
Join Date: Oct 2009
Posts: 1
Thanks: 0
fvisic is on a distinguished road
Default

You can use this ....

TABLE (primary key "parent, child")
|parent | child | s_name | url
| ----- | 00001 | menu 1 | view.php?p=1
| ----- | 00002 | menu 2 | view.php?p=2
| ----- | 00003 | menu 3 | view.php?p=3
| ----- | 00004 | menu 4 | view.php?p=4
| 00001 | 00005 | Testing menus 1.1 | view.php?p=1&action=1
| 00001 | 00006 | Testing menus 1.2 | view.php?p=1&action=2
| 00001 | 00007 | Testing menus 1.3 | view.php?p=1&action=3
| 00001 | 00008 | Testing menus 1.4 | view.php?p=1&action=4
| 00002 | 00009 | Testing menus 2.1 | view.php?p=2&action=1
| 00002 | 00010 | Testing menus 2.2 | view.php?p=2&action=2
| 00002 | 00011 | Testing menus 2.3 | view.php?p=2&action=3
| 00002 | 00012 | Testing menus 2.4 | view.php?p=2&action=4
| 00012 | 00013 | Testing menus 2.4.1 | view.php?p=2&action=4&subacction=1
...
etc.

You must use recursion for every child
First level
SELECT * FROM table WHERE parent='-----'
second level
SELECT * FROM table WHERE parent='00001'

.....................
SELECT * FROM table WHERE parent='00002'

................
SELECT * FROM table WHERE parent='00012'

Last edited by fvisic : 10-27-2009 at 05:46 PM.
fvisic is offline  
Reply With Quote
Old 10-30-2009, 08:34 AM   #5 (permalink)
The Wanderer
 
mombunheng's Avatar
 
Join Date: Oct 2009
Posts: 5
Thanks: 0
mombunheng is on a distinguished road
Default

thanks for your participation for the menus design, I am currently using the following code let me know if you have any idea better than this.

CODE:
----------------------------------------------
<ul>
<li class="maintitle"><a href="/wcscambodia/section.php?sectid=<?php echo $sectid;?>"><?php echo $sect_name;?></a></li>
<?php
$currentcat = (int)($_GET['catid']);
$listid = '';
$sql = "SELECT cat_label, cat_id FROM tblcategories WHERE parent_sect = $sectid";
$result = dbQuery($sql);
while ($row = dbFetchAssoc($result)) {
?>

<li<?php if ($row['cat_id'] == $currentcat){$listid = ' id="current"'; echo $listid; }?>>
<a href="subsection.php?catid=<?php echo $row['cat_id'];?>"><?php echo $row['cat_label'];?></a>
</li>
<?php
if ($row['cat_id'] == $currentcat){
echo '<ul class="subul">';
$sqlm = "SELECT * FROM tblarticle WHERE article_cat = $currentcat";
$mresult = dbQuery($sqlm);
while ($rowm = dbFetchAssoc($mresult)){
?>
<li class="article"><a href="article.php?catid=<?php echo $currentcat;?>&page=<?php echo $rowm['article_id'];?>"><?php echo $rowm['article_title']?></a></li>
<?php
}
echo '</ul>';
}
?>
<?php }?>
</ul>
mombunheng is offline  
Reply With Quote
Old 11-06-2009, 04:15 AM   #6 (permalink)
The Contributor
 
Join Date: Jun 2009
Location: Seattle, WA
Posts: 76
Thanks: 1
rguy84 is on a distinguished road
Default

I have made menus like this using straight php, not a database. how are the pages saved in the database?
__________________
Ryan | Blog | Twitter
Send a message via AIM to rguy84 Send a message via MSN to rguy84 Send a message via Yahoo to rguy84 Send a message via Skype™ to rguy84
rguy84 is offline  
Reply With Quote
Old 02-19-2010, 08:33 AM   #7 (permalink)
The Wanderer
 
mombunheng's Avatar
 
Join Date: Oct 2009
Posts: 5
Thanks: 0
mombunheng is on a distinguished road
Default

Hi, originally the each menus have destination link or page ID, it looks like joomla framework, I am currently use on some project, I am looking for shorter way and fast performance.
mombunheng is offline  
Reply With Quote
Old 02-19-2010, 05:17 PM   #8 (permalink)
The Contributor
 
Join Date: Jun 2009
Location: Seattle, WA
Posts: 76
Thanks: 1
rguy84 is on a distinguished road
Default

Are you legitimately still working on this? I only ask since it took over 3 months to get a reply. I haven't used Joomla much, so I don't know what you mean by it looks like joomla. Remember all a framework is is a pre-defined set of classes and/or functions, basically making your life/work easier.
__________________
Ryan | Blog | Twitter
Send a message via AIM to rguy84 Send a message via MSN to rguy84 Send a message via Yahoo to rguy84 Send a message via Skype™ to rguy84
rguy84 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
Help on PHP MYSQL Forms Input deesudesu Absolute Beginners 1 03-20-2009 10:50 AM
Basic php form update mysql script dp2 Absolute Beginners 3 03-11-2009 04:06 PM
how to call mysql procedures in php??? gptArun Absolute Beginners 7 06-05-2008 08:13 PM
Rating System: AJAX, MYSQL, PHP Orc General 6 02-26-2008 05:09 PM
Error in connecting to MySQL via PHP EyeDentify MySQL & Databases 0 01-03-2008 01:06 PM


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