Hello All
Please help me how to create Menu->submenu->subsubmenu using php/mysql with coding help me please. Inserting data into it also.
Thanks in advance
Hello All
Please help me how to create Menu->submenu->subsubmenu using php/mysql with coding help me please. Inserting data into it also.
Thanks in advance
Here is an article about this: Storing Hierarchical Data in a Database
hi bogu
thanks for your quick reply.
I am unable to populate following menu using the above link. please correct my code
my list is somewhat like this below
programs of study
Calendars
Catalogs
Class Schedules
Financial Services
Learner Services
Enrollment Management (submenu)
Media Center
Online Book Store
Online Learning
Weather Policy
using the following code i am not getting subsub code
<?php
$connec=mysql_connect("localhost","root","")or die(mysql_error());
?>
<?php
$sele=mysql_select_db("watc",$connec)or die (mysql_error());
$query = "SELECT * FROM tbl_watc_menu where parent_id=0";
$treeGearRS = mysql_query($query,$connec) or die(mysql_error());
$row_treeGearRS = mysql_fetch_assoc($treeGearRS);
$totalRows_treeGearRS = mysql_num_rows($treeGearRS);
?>
<html>
<head>
<style>
SPAN.TreeviewSpanArea A {
font-size: 10pt;
font-family: verdana,helvetica;
text-decoration: none;
color: black
}
SPAN.TreeviewSpanArea A:hover {
color: '#820082';
}
/* rest of the document */
BODY {background-color: white}
TD {
font-size: 10pt;
font-family: verdana,helvetica;
}
</style>
<script>
function getQueryString(index)
{
var paramExpressions;
var param
var val
paramExpressions = window.location.search.substr(1).split("&");
if (index < paramExpressions.length)
{
param = paramExpressions[index];
if (param.length > 0) {
return eval(unescape(param));
}
}
return ""
}
</script>
<script src="ua.js"></script>
<script src="ftiens4.js"></script>
<script language="JavaScript" type="text/JavaScript">
USETEXTLINKS = 1
STARTALLOPEN = 1
USEFRAMES = 0
USEICONS = 0
WRAPTEXT = 1
PRESERVESTATE = 1
HIGHLIGHT = 1
foldersTree = gFld("<b>watc</b>", "#")
aux2 = insFld(foldersTree, gFld("programs of study", ""))
</script>
<?php
while($row_treeGearRS = mysql_fetch_assoc($treeGearRS) )
{
?>
<script>
aux2 = insFld(foldersTree, gFld("<? echo $row_treeGearRS['menu_name']; ?>", "<? echo $row_treeGearRS['menu_name']; ?>"))</script>
<script>
insDoc('', gLnk("S", "<?php echo $row_treeGearRS['menu_name']; ?>", "<?php echo $row_treeGearRS['menu_name']; ?>"))</script>
<?php $sqlquery="select * from tbl_watc_menu where parent_id=".$row_treeGearRS['menu_id'];
$sqlresour=mysql_query($sqlquery);
while($resource=mysql_fetch_array($sqlresour)){
?> <script>
insDoc(aux2, gLnk("S", "<?php echo $resource['menu_name']; ?>", "<?php echo $resource['menu_name']; ?>"))</script>
<?php } }?>
</script>
</script>
</head>
<body bgcolor=white leftmargin=0 topmargin=0 marginheight="0" marginwidth="0" onResize="if (navigator.family == 'nn4') window.location.reload()">
<table cellpadding=0 cellspacing=0 border=0 width=772><tr><td width=772>
</td>
</table>
<table cellpadding=0 cellspacing=0 border=0 width=772>
<tr>
<td width=178 valign=top>
<table cellpadding=4 cellspacing=0 border=0 width=100%><tr><td bgcolor=#ECECD9>
<img src=http://www.treeview.net/treemenu/layout/t.gif width=170 height=1><br>
<table cellspacing=0 cellpadding=2 border=0 width=100%><tr><td bgcolor=white>
<table border=0><tr><td><font size=-2><a style="font-size:7pt;text-decoration:none;color:while" href=# target=_blank></a></font></td></table>
<span class=TreeviewSpanArea>
<script>initializeDocument()</script>
<noscript>
A tree for site navigation will open here if you enable JavaScript in your browser.
</noscript>
</span>
<!-- SECTION 7: Continuation of the body of the page, after the tree. Replace whole section with
your site's HTML. -->
</td></tr></table></table>
</td>
<td bgcolor=white valign=top>
<table cellpadding=10 cellspacing=0 border=0 width=100%><tr><td><p> </p></td>
</table></td></table>
</body>
</html>
<?php
mysql_free_result($treeGearRS);
?>
my database table is like this below
CREATE TABLE `tbl_watc_menu` (
`menu_id` int(11) NOT NULL auto_increment,
`menu_name` varchar(150) default NULL,
`parent_id` int(11) default NULL,
`content_type` char(1) default NULL,
`delete_status` char(1) default NULL,
`active_status` char(1) default NULL,
`sort_order` int(11) default NULL,
`gra_parent_id` int(11) default NULL,
PRIMARY KEY (`menu_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
#
# Dumping data for table tbl_watc_menu
#
INSERT INTO `tbl_watc_menu` VALUES (1,'Programs of Study',0,'c',NULL,NULL,NULL,NULL);
INSERT INTO `tbl_watc_menu` VALUES (2,'Calendars',0,'f',NULL,NULL,NULL,NULL);
INSERT INTO `tbl_watc_menu` VALUES (3,'Catalogs',0,'f',NULL,NULL,NULL,NULL);
INSERT INTO `tbl_watc_menu` VALUES (4,'Class Schedules',0,'c',NULL,NULL,NULL,NULL);
INSERT INTO `tbl_watc_menu` VALUES (5,'Financial Services',0,'c',NULL,NULL,NULL,NULL);
INSERT INTO `tbl_watc_menu` VALUES (6,'Learner Services',0,'b',NULL,NULL,NULL,NULL);
INSERT INTO `tbl_watc_menu` VALUES (7,'Library and Learning Resource Center\r\n',0,'c',NULL,NULL,NULL,NULL);
INSERT INTO `tbl_watc_menu` VALUES (8,'Media Center',0,'l',NULL,NULL,NULL,NULL);
INSERT INTO `tbl_watc_menu` VALUES (9,'Online Book Store',0,'b',NULL,NULL,NULL,NULL);
INSERT INTO `tbl_watc_menu` VALUES (10,'Online Learning',0,'b',NULL,NULL,NULL,NULL);
INSERT INTO `tbl_watc_menu` VALUES (11,'Weather Policy',0,'b',NULL,NULL,NULL,NULL);
INSERT INTO `tbl_watc_menu` VALUES (12,'Enrollment Management',6,'b',NULL,NULL,NULL,NULL);
INSERT INTO `tbl_watc_menu` VALUES (13,'test',12,NULL,NULL,NULL,NULL,1);
i am getting following
programs of study
Calendars
Catalogs
Class Schedules
Financial Services
Learner Services
Enrollment Management
Media Center
Online Book Store
Online Learning
Weather Policy
thread_PHP wrote:I am unable to populate following menu using the above link. please correct my code
Your code is not like the one in the link I gave u above, there is nothing to correct is the algorithm that counts, how to create your DB tables structure to suit your needs ...
You should read the article that I gave u and try it that way, or if u don't like it there are plenty of other articles on the net ...
For this kind of job is to much to explain that's why I send u to a tutorial ...