joomla
asked on
nested loop accordian menus
I have a function for creating a nested UL based on data in my MYSQL table
.... thanks shahzadfatehali for recent help
I want to format the UL so I can use it in the script for creating accordian menus
http://www.dynamicdrive.com/dynamicindex17/ddaccordion.htm
function createMenu1($parentid) {
$Result = mysql_query("SELECT * FROM tblcategory WHERE Status=1 and ParentCategoryID = '".$parentid."'");
$output = '';
if(mysql_num_rows($Result) > 0){
$output .= '<ul>';
while ($Row = mysql_fetch_assoc($Result) ) {
$output .= '<li>'.$Row['CategoryName' ];
$output .= createMenu1($Row['Category ID']);
$output .= '</li>';
}
$output .= '</ul>';
}
mysql_free_result($Result) ;
return $output;
}
.... thanks shahzadfatehali for recent help
I want to format the UL so I can use it in the script for creating accordian menus
http://www.dynamicdrive.com/dynamicindex17/ddaccordion.htm
function createMenu1($parentid) {
$Result = mysql_query("SELECT * FROM tblcategory WHERE Status=1 and ParentCategoryID = '".$parentid."'");
$output = '';
if(mysql_num_rows($Result)
$output .= '<ul>';
while ($Row = mysql_fetch_assoc($Result)
$output .= '<li>'.$Row['CategoryName'
$output .= createMenu1($Row['Category
$output .= '</li>';
}
$output .= '</ul>';
}
mysql_free_result($Result)
return $output;
}
ASKER
Yes, I noticed that link and examined that code they supply for subcategories.
The challenge here is to apply the categoryitems and subcategoryitems to the appropriate UL within the nested loop.
thanks
The challenge here is to apply the categoryitems and subcategoryitems to the appropriate UL within the nested loop.
thanks
PHP function takes care of it. Did you try it?
ASKER
Yes, I tried it
you'll notice in the code within http://www.dynamicdrive.com/dynamicindex17/ddaccordionmenu-bullet.htm
it refers to "categoryitems" & "subcategoryitems".
it is specially this which is causig me the trouple
you'll notice in the code within http://www.dynamicdrive.com/dynamicindex17/ddaccordionmenu-bullet.htm
it refers to "categoryitems" & "subcategoryitems".
it is specially this which is causig me the trouple
paste your code and i will modify fix it
ASKER
Hi shahzadfatehali:
sorry I was unavailable yesterday
I'm don't have any code that actually works
function createMenu1($parentid) {
global $objDB;
$SQL="SELECT * FROM tblcategory WHERE Status=1 and ParentCategoryID = '".$parentid."'";
//echo $SQL; die;
$rs=$objDB->select($SQL);
$output = '';
if(count($rs) > 0){
$output .= '<ul class="subcategoryitems">' ;
for($i=0;$i<count($rs);$i+ +) {
$output .= '<li><a href="index1.php?p=cms&CMS ID='.$rs[$ i]["CMSID" ].'" class="subexpandable" >'.$rs[$i]["CategoryName"] .'</a>';
$output .= createMenu1($rs[$i]['Categ oryID']);
$output .= '</li>';
}
$output .= '</ul>';
}
return $output;
}
Here is a url in which the top menu cascades properly
http://www.bluelilyclients.com/idh/index1.php?p=accordian
Note that under 'about us' there are a number of submenu with tickmaks
The url also shows the attempted accordion menu
sorry I was unavailable yesterday
I'm don't have any code that actually works
function createMenu1($parentid) {
global $objDB;
$SQL="SELECT * FROM tblcategory WHERE Status=1 and ParentCategoryID = '".$parentid."'";
//echo $SQL; die;
$rs=$objDB->select($SQL);
$output = '';
if(count($rs) > 0){
$output .= '<ul class="subcategoryitems">'
for($i=0;$i<count($rs);$i+
$output .= '<li><a href="index1.php?p=cms&CMS
$output .= createMenu1($rs[$i]['Categ
$output .= '</li>';
}
$output .= '</ul>';
}
return $output;
}
Here is a url in which the top menu cascades properly
http://www.bluelilyclients.com/idh/index1.php?p=accordian
Note that under 'about us' there are a number of submenu with tickmaks
The url also shows the attempted accordion menu
ASKER
I suspect I have to find a way to correctly identify each li that contains a submenu and not close that li until all children have been crawled
I guess your problem will be resolved if you replace class="subcategoryitems" with some unique work or use id instead. You are using same class for all sub <UL>s with make them hidden.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.dynamicdrive.com/dynamicindex17/ddaccordionmenu-bullet.htm
and the html generated by above code will work.