Monday, 22 April 2013

Display Submenu when Hoever Main Menu

Menu Concepts



style.css

<style type="text/css" >
div
{
    background-color:#999;
    border:1px;
    margin:50px auto;
    margin-left:300px;
    width:60%;
    line-height:20px;,.
}
div div h1
{
    line-height:50px;
    margin:0 auto;
    
}
#c
{
    color:#006;

    margin-left:210px;
}

#o
{
    height:40px;
    line-height:30px;
}
div p{
    
    line-height:10px;
    margin-left:40px;
}
.menu 
{
color:#309; padding:0; height:25px;width:800px;

}
.menu li
{
float:left;
display:inline;padding:0;  
width:160px;  height:2opx;
text-align:center;
}
.menu li:hover
{
float:left;
background-color:#FF6699;
text-align:center; padding:0;
}
 
.menu li ul {visibility:hidden; }
.menu li:hover ul { visibility:visible; padding:0; border:1 red solid;}
</style>

index.php


<?php
$cnt=mysql_connect("localhost","root","");
$select_db=mysql_select_db("menu",$cnt);

if(isset($_POST['submit']))
{
    $m=$_POST['mainmenu'];
    print_r($_POST);
    $insert=mysql_query("insert into menu_tb(menu) value('$m')",$cnt) or die(mysql_error());
    
}
if(isset($_POST['sub']))
{
    $e=$_POST['submenu'];
    $t=$_POST['menus'];
    print_r($_POST);
    $insert=mysql_query("insert into submenu(menuid,submenu) value('$e','$t')",$cnt) or die(mysql_error());
    
}
?>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Menu Bar Concept</title>

</head>

<body>
<form name="form" method="post" action="">
<div>
<div><h1>Menu Concept</h1></div>
<div id="c">

Menu List &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    <input type="text" name="mainmenu" value="" /></div>

<div id="o"><p><input type="submit" name="submit" value="submit" /></p></div>
</div>

<div>



</form>

<form method="post" action="" name="form2">
<div><h1>Menu Concept</h1></div>

<div id="c">
Menu List
<select name="submenu">

<option value="">---Select anyone---</option>
<?php
$cnt=mysql_connect("localhost","root","");
$select_db=mysql_select_db("menu",$cnt);
$select=mysql_query("select * from menu_tb",$cnt);
while($r=mysql_fetch_array($select))
{
    ?>
    <option value="<?php echo $r['id'];?>">
    <?php echo $r['menu'];?></option>
    <?php
}
?>
</select><br />
<br />

SELECT SUB MENU&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="menus" value="" />
</div>
<div id="o"><p><input type="submit" name="sub" value="submenu_submit" /></p></div>
</div>


</form>
<form name="form3" action="" method="post">

<div id="d">
<ul class="menu">
<?php
      $cnt=mysql_connect("localhost","root","");
$select_db=mysql_select_db("menu",$cnt);
       $select_table=mysql_query("select * from menu_tb");
 while($row=mysql_fetch_array($select_table))
{
?>
      <li><a href=""><?php echo $row['menu'];?></a>
      <?php 
  $select=mysql_query("select * from submenu where menuid='$row[id]'");
  if(mysql_num_rows($select)<=0)
    {
  }
  else
    {
 
?>
      
        <ul>
        <?php
while($submenu=mysql_fetch_array($select))
{
?>
        <li> <a href=""><?php echo $submenu['submenu']; ?></a></li>
                <?php
}
?>
        </ul>
      
        <?php
  }
    ?>
       </li>
     <?php
 }
?>
  </ul>
</div>

</form>

</body>
</html>

No comments:

Post a Comment