Server IP : 184.154.167.98 / Your IP : 18.227.0.21 Web Server : Apache System : Linux pink.dnsnetservice.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 User : puertode ( 1767) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/puertode/public_html/oficios/sis/ |
Upload File : |
<?php function display_menu(){ $servername = "localhost"; $username = "root"; $password = ""; $dbname = "dynamo"; $connect = new mysqli($servername, $username, $password, $dbname); $menus = ""; $menus .= multilevel_menu($connect); return "<ul class='main_ul'>".$menus."</ul>"; } function multilevel_menu($connect, $parent_id=NULL){ $menu = ""; if(is_null($parent_id)){ $sql = "SELECT * FROM dynamic_menu WHERE parent_id IS NULL"; }else{ $sql = "SELECT * FROM dynamic_menu WHERE parent_id = $parent_id"; } $result = mysqli_query($connect, $sql); while($row = mysqli_fetch_assoc($result)) { if($row["parent_id"]){ $menu .= "<li class='sub_li'>".$row['name']; }else{ $menu .= "<li class='main_li' >".$row['name']; } $row_id = $row["id"]; $sql_b = "SELECT * FROM dynamic_menu WHERE parent_id = $row_id"; $count = mysqli_query($connect, $sql_b); if($count->num_rows > 0){ $menu .= "<ul class='sub_ul'>".multilevel_menu($connect, $row["id"])."</ul>"; }else{ $menu .= multilevel_menu($connect, $row["id"]); } $menu .= "</li>"; } return $menu; } echo display_menu(); ?>