I need to use HierMenus (www.dhtml.com) for a site but my problem is how to get the MySQL data
in to the Javascript.
I need to print out the following javascipt using the the vars from the MySql database.
HM_Array2_2 = [
[],
["Data Acquisition","http://",1,0,1],
["Industrial IT","http://",1,0,0]
]
HM_Array2_2_1 = [
[],
["Analog Input","http://",1,0,0],
["Digital Input","http://",1,0,1],
["Analog Input/Output","http://",1,0,1],
["Digital Input/Output","http://",1,0,0],
["Multi Function I/O","http://",1,0,0],
["Accessories","http://",1,0,0]
]
HM_Array2_2_1_2 = [
[],
["8/16/24 Channels","http://",1,0,0],
["48/104/256 Channels","http://",1,0,0],
["Accessories","http://",1,0,0]
]
I'm using the following code for the webadmin section:
<select name="test">
<?php
include("inc/dbase.php");
include("inc/config.php");
$sqlmenu = new CDBMySQL($DbaseConnectionHost, $DbaseConnectionLogin, $DbaseConnectionPass, $DbaseConnectionName);
$sqlmenu -> Query ("SELECT * from tblcategory order by subcategory_name");
while ($sqlmenu -> ReadRow()) {
$tmpAry[$sqlmenu -> RowData["subcategory_parent"]][$sqlmenu -> RowData["subcategory_id"]] = $sqlmenu -> RowData["subcategory_name"];
}
$sqlmenu ->Close;
sortCategories($tmpAry, $ary, 0, "");
//print_r($ary);
while (list ($id, $name) = each ($ary)){
echo "<option value=$id>$name</option>
";
}
function sortCategories(&$inAry, &$outAry, $level, $indent) {
if( is_array($inAry[$level]) ) {
while( list($id, $name) = each($inAry[$level]) ) {
$outAry[$id] = "$indent $name";
sortCategories($inAry, $outAry, $id, "$indent $name > ");
}
}
}
?>
</select>
And it works fine.
Any Ideas, Code, Help?
Regards,
Johan Hanekom
johan@storm-digital.com