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.

Recommended Answers

All 4 Replies

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

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

$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"];
    if($parentid == -1)
            $str .= "<li><a href='#'>$title</a></li>";
            $str .= "<li><a href='#'>$title</a>";
                $str .= "<div>";

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

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

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

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, learning, and sharing knowledge.