Create Dynamic Sidebar Multilevel Menu in AdminLTE with MySQL ,PHP and PDO

Creating dynamic sidebar menu on adminLTE using MySQL, PHP, and PDO. Continuing my previous article Creating Dynamic sidebar menu with Mysql and AdminLTE Bootstrap Template. There are still many visitors who ask about the script. Here I will share a more complex tutorial, but it is easier to understand for beginners (hopefully). Let’s start the tutorial

Create Dynamic Sidebar Multilevel Menu In AdminLTE With MySQL ,PHP And PDO

Tutorial how to create dynamic sidebar multilevel menu in MySQL, PHP, and AdminLTE template

1. Create new MySQL database with name “dbmenu
2. Please create 3 new table with the name r_menu, r_menu_sub, r_menu_sub_level_2
3. Insert three tables with the following query

r_menu table

R Menu Table Create Dynamic Sidebar Multilevel Menu In AdminLTE With MySQL ,PHP And PDO

r_menu_sub table

R Menu Sub Table Create Dynamic Sidebar Multilevel Menu In AdminLTE With MySQL ,PHP And PDO

r_menu_sub_level_2 table

R Menu Sub Level 2 Table Create Dynamic Sidebar Multilevel Menu In AdminLTE With MySQL ,PHP And PDO

4. Create new project folder with the named “dinamikmenu“.
5. Copying AdminLTE template in the dinamikmenu folder. Please download an adminLTE template here if you doesn’t have it.

Folder Structure

6. Create a new folder with name “model” in the dinamikmenu folder. This folder is used to store 2 PHP file that is used to connect PHP and MySQL with PDO.
7. Create a PHP file with the name sql.php and dbconn.php. Copy the following code

dbconn.php

Description :

A class above are used to connect MySQL database with PHP using PDO. Customize with your database settings

sql.php

Description :

A class above are used to accommodate the function query the database using PDO.

public function getMenu() : used to query table r_menu

getSubMenu($id) : used to query table r_menu_sub based id_menu

getSubMenuLevel2($id) : used to query table r_menu_sub_level_2 based id_sub_menu

8. Copy the code below and paste the following code below adminLTE sidebar.

Or download the entire full source code in the bottom article

Up to this point, you have finished creating dynamic sidebar menu adminLTE. Try on your browser and make sure as shown below :

Tutorial How To Create Dynamic Sidebar Menu On AdminLTE With Php And Mysql

How ? very easy right

To download the full source code above, please download via the following URL. To open a URL link, please share this article by pressing the share button below.

Thus the article about Create Dynamic Sidebar Multilevel Menu in AdminLTE with MySQL ,PHP, and PDO, hope useful:)

The following two tabs change content below.
This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.

Leave a Comment

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.