
December 25th, 2002, 08:46 AM
|
|
Junior Member
|
|
Join Date: Dec 2002
Posts: 3
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
OK, Please read the article I mentioned in my first post. 99% of the code comes from there, I just changed it a little bit. Remember, I have a framset page of 2 frames -- left and right. The left frame is where this code goes. Additionally, the only modification I made to the menu table (see article) is that I added 2 more columns. One called target and one called onclick. They are both VARCHAR(50). The reason for the addition is so that when I click on a link in the menu I can open the new page in a particular frame or as a new page (hence, the target) and to be able to open 2 frames with one click (hence, the onclick). Here is the code for menu.php. I hope this makes sence, if not, send me a message and I will write a step by step modifications I made.
The relevant portion of the code is this:
Code:
<a href="<?php echo $child[2]; ?>" target="<?php echo $child[4]; ?>" onclick="<?php echo $child[5]; ?>"><?php echo $child[1]; ?></a>
And the rest is here ...
Code:
<?php
// Create our database connection
$sqlConn = mysql_connect("localhost", "admin", "somepassword") or die("Couldn't connect to database");
$dbConn = mysql_select_db("menu", $sqlConn) or die("Couldn't connect to database");
$sql = "select * from nodespnp where parentId = 0 order by nodeId asc";
$nodeResult = mysql_query($sql) or die("SELECT query failed");
$counter = 0;
?>
<html>
<head>
<title> Dynamic Menus </title>
<base target="right">
<style>
.root_td
{
background-color: #000000;
color: #FFCF00;
font-family: Verdana;
font-size: 8pt;
font-weight: bold;
height: 22;
padding-left: 5;
}
.child_td
{
background-color: #D1D1D1;
color: #000000;
font-family: Verdana;
font-size: 8pt;
font-weight: bold;
text-decoration: underline;
height: 22;
padding-left: 10;
padding-right: 10;
padding-bottom: 3;
}
body
{
color: #000000;
font-family: Verdana;
font-size: 8pt;
font-weight: normal;
}
a
{
color: #000000;
}
</style>
<script language="JavaScript">
function ToggleNode(nodeObject, imgObject)
{
if(nodeObject.style.display == '' || nodeObject.style.display == 'inline')
{
nodeObject.style.display = 'none';
imgObject.src = 'plus.gif';
}
else
{
nodeObject.style.display = 'inline';
imgObject.src = 'minus.gif';
}
}
</script>
</head>
<body bgcolor="#FFFFFF">
<table width="200" border="0" cellspacing="0" cellpadding="0">
<?php
while($node = mysql_fetch_array($nodeResult))
{
?>
<tr>
<td class="root_td">
<img id="img_root_<?php echo $counter; ?>" onClick="ToggleNode(td_root_<?php echo $counter; ?>, img_root_<?php echo $counter; ?>)" border="0" src="minus.gif" style="cursor:hand">
<?php echo $node[1]; ?>
</td>
</tr>
<tr>
<td id="td_root_<?php echo $counter++; ?>" class="child_td">
<table width="100%">
<?php
$sql = "select * from nodespnp where parentId = {$node[0]} order by nodeId asc";
@$childResult = mysql_query($sql);
while($child = mysql_fetch_row($childResult))
{
?>
<tr>
<td class="child_td">
<a href="<?php echo $child[2]; ?>" target="<?php echo $child[4]; ?>" onclick="<?php echo $child[5]; ?>"><?php echo $child[1]; ?></a>
</td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
<?php
}
?>
</table>
</body>
</html>
|