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.

Can you show an example of what you want to build?

You can use that code as an example, what's the problem?

<?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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.