0

I'm Anil kumar i want to build a dynamic mega drop down menu using PHP.

how to create table structure?

how to write the code for doing this?

please help me.

2
Contributors
4
Replies
21
Views
4 Years
Discussion Span
Last Post by anil14353
0
<?php
$sql="SELECT * FROM headermenu";
$result = mysql_query($sql) or die(mysql_error());
$str = "";

while ($row = mysql_fetch_array($result)) 
{
    $id =  $row["id"];
    $parentid =  $row["PARENTID"];
    $title =  $row["title"];
    $has_child =  $row["HAS_CHILD"];
    $subid=$row['subid'];
    $cols=$row['cols'];
    if($parentid == -1)
    {
        if($has_child==0)
        {
            $str .= "<li><a href='#'>$title</a></li>";
        }
        if($has_child==1)
        {
            $i=0;
            $items=10;
            $str .= "<li><a href='#'>$title</a>";
                $str .= "<div>";
            while($i<$cols)
            {

                $sql2=mysql_query("SELECT *,a.title as htitle FROM headermenu a WHERE a.PARENTID=$id") or die(mysql_error());
                $fet=mysql_fetch_array($sql2);
                $str .='<div class="nav-column">';
                while($row2 = mysql_fetch_array($sql2)) 
                {

                    $title2 = $row2["htitle"];
                    $str .= "<li><a href='#'>$title2</a></li>";
                }
                $i++;
                $str .= "</div>";    
            }
            $str .= "</div>";
                $str .= "</li>";
        }
    }
}
?>

<html>
<head>
<style>
.wrap {width: 960px; margin: 0 auto;}
</style>
</head>
<body>
<div id="wrapper">
    <ul class="mega-menu">
        <?php echo $str; ?>
    </ul>
</div>
</body>
</html>

i had this one but this will give only single column sub menu but i want a sub menu with two or three columns.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.