NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page collapsing menu

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 06-21-2006, 11:54 AM THREAD STARTER               #1 (permalink)
Senior Member
 
killaklown's Avatar
Join Date: Oct 2003
Posts: 3,472
killaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to behold
 



collapsing menu


Im working on the menu at my site http://tutorialhit.com/index.php

i want to be able to click the main category (in this case, only one is there, and called PHP coding) and it would display all of the sub-categories in only that category (there will be more main categories added). Then if you click the PHP coding category again, the sub-categories go away again.

The categories are all in the mysql database

This is the code for the subcategories

PHP Code:
        if(count($children)>"0"&&$foetus!="") {
            foreach(
$children as $child) {
                
$k++;
                
$title mysql_result(mysql_query("SELECT * FROM tdb_categories WHERE id='$child' LIMIT 1"), "0""title");
                
$stati mysql_result(mysql_query("SELECT * FROM tdb_categories WHERE id='$child' LIMIT 1"), "0""status");
????: NamePros.com http://www.namepros.com/programming/209454-collapsing-menu.html
                if(
$stati=="open") {
????: NamePros.com http://www.namepros.com/showthread.php?t=209454
                    
$colspan "1";
                    
$link '<a href="list.php?cat='.$child.'">'.$title.'</a></td><td class="info">'.mysql_numrows(mysql_query("SELECT * FROM tdb_tutorials WHERE cat='$child' AND status='accepted'")).' &times;';
                } else {
                    
$link ''.$title.'';
                    
$colspan "2";
                }
                echo 
'<tr class="menu'.$k.'subcat"><td class="link" colspan="'.$colspan.'">'.$link.'</td></tr>';
                if(
$k=="2") {
                    
$k "0";
                }
            }
        } 
If you dont know what i mean, i found an example: http://www.chipchapin.com/WebTools/M...6/demo_win.php



If i know the code on how to make you click on a link and gives text to a certain variable but the page doesnt reload or something, then i can probably do it.

Ie
PHP Code:
$activelink="";

//code to click the text below and add $title (category title) to the variable
Category name

// Then display sub-categories whos parent is $title (category title that was clicked) 
Last edited by killaklown; 06-21-2006 at 12:20 PM.
killaklown is offline  
Old 06-21-2006, 12:30 PM   #2 (permalink)
NamePros Regular
 
hairyfreak's Avatar
Join Date: Dec 2005
Location: Derbyshire, UK
Posts: 887
hairyfreak is just really nicehairyfreak is just really nicehairyfreak is just really nicehairyfreak is just really nice
 



These three links should help, I think they are what you are after:

http://www.dynamicdrive.com/dynamici...switchmenu.htm
http://www.dynamicdrive.com/dynamici...witchmenu2.htm
http://www.dynamicdrive.com/dynamicindex1/navigate2.htm

The first is almost the same as the demo you posted. The second is similar, but has a smoother effect. The third is like the first, but allows more information.
hairyfreak is offline  
Old 06-21-2006, 12:36 PM THREAD STARTER               #3 (permalink)
Senior Member
 
killaklown's Avatar
Join Date: Oct 2003
Posts: 3,472
killaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to beholdkillaklown is a splendid one to behold
 



I dont think that would work for me, because there would be no way to tell what category was clicked and what subcategories to display.
killaklown is offline  
Old 06-21-2006, 04:28 PM   #4 (permalink)
Resistance is Futile
 
Kadenz's Avatar
Join Date: Apr 2006
Location: Montreal, Canada
Posts: 1,094
Kadenz is a name known to allKadenz is a name known to allKadenz is a name known to allKadenz is a name known to allKadenz is a name known to allKadenz is a name known to all
 



Wildlife Lou Gehrig's Disease (ALS)
I'm trying to figure out how to implement it into the PHP, but here's the Javascript:
Code:
<script type="text/javascript">
function showList(element) {
if (document.getElementById(element).style.visibility == "collapse") {
document.getElementById(element).style.visibility = "visible";
} else {
document.getElementById(element).style.visibility = "collapse";
}
}
</script>
This worked for me:
PHP Code:
<?
$sql 
mysql_query("SELECT * FROM db WHERE status='0'");
while (
$row mysql_fetch_object($sqlMYSQL_BOTH)) {
    echo 
'<strong><a href="javascript:showList(\''.$row->TITLE.'\');">'.$row->TITLE.'</a></strong><br />
    <table width="100%" border="0" cellspacing="0" cellpadding="0" style="visibility:collapse;" id="'
.$row->TITLE.'">';
     
$sql2 mysql_query("SELECT * FROM db WHERE PARENT = '".$row->TITLE."' AND STATUS = '1'");
????: NamePros.com http://www.namepros.com/showthread.php?t=209454
     while (
$row2 mysql_fetch_object($sql2MYSQL_BOTH)) {
     echo 
'<tr><td><a href="'.$row2->LINK.'" target="_blank">'.$row2->TITLE.'</a></td></tr>';
     }
????: NamePros.com http://www.namepros.com/showthread.php?t=209454
     echo 
'</table>';
}
?>
__________________
Freelance Web Developer
PHP, MySQL, XHTML, CSS, Javascript, jQuery, Wordpress
Portfolio: www.bundy.ca
Kadenz is offline  
Closed Thread


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


Liquid Web Smart Servers  
All times are GMT -7. The time now is 12:44 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger