• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
seegatesite header

Seegatesite.com

Seegatesite.com - Programming Tutorial , Sharing , How and Learn Together

  • TOOLS
    • Bootstrap Navbar Online Generator
    • Customize Sidebar Menu Bootstrap 3
    • Bootstrap Demo
  • ADVERTISE
  • CATEGORIES
    • Android
    • Blogging Tips
    • Database
    • CSS
    • Info Gadget
    • Javascript
    • Linux
    • PHP
    • Various
    • WordPress
  • Q&A
  • PHP
  • JAVASCRIPT
  • JQUERY
  • ANGULAR
  • WORDPRESS
  • SEO
  • REACT
🏠 » PHP » Create Dynamic Sidebar Multilevel Menu in AdminLTE with MySQL ,PHP and PDO

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

By Sigit Prasetya Nugroho ∙ December 11, 2016 ∙ PHP ∙ 9 Comments

Share : TwitterFacebookTelegramWhatsapp

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

Table of Contents

  • 1 Tutorial how to create dynamic sidebar multilevel menu in MySQL, PHP, and AdminLTE template
    • 1.1 Thus the article about Create Dynamic Sidebar Multilevel Menu in AdminLTE with MySQL ,PHP, and PDO, hope useful:)

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

Related Articles :

  • How To Upload Image Using PHP, AdminLTE Framework And JQuery Plugin For Beginner
  • Create a Sales Form / POS – Tutorial Build Point Of Sale With PHP, PDO, MySQL And Jquery Part 5
  • Create Master Item / Product Form – Tutorial Build Point Of Sale With PHP, PDO, MySQL And Jquery Part 4.

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

1
2
3
4
5
6
7
insert  into `r_menu`(`id_menu`,`nama_menu`,`urutan`,`icon`,`newclass`) values (1,'Multilevel Menu',1,'<i class=\"fa fa-dashboard\"></i','first_class');
insert  into `r_menu`(`id_menu`,`nama_menu`,`urutan`,`icon`,`newclass`) values (2,'Penjualan',2,'<i class=\"fa fa-files-o\"></i','second_class');
insert  into `r_menu`(`id_menu`,`nama_menu`,`urutan`,`icon`,`newclass`) values (3,'Pembelian',3,'<i class=\"fa fa-th\"></i','third_class');
insert  into `r_menu`(`id_menu`,`nama_menu`,`urutan`,`icon`,`newclass`) values (4,'Laporan',6,'<i class=\"fa fa-dashboard\"></i',NULL);
insert  into `r_menu`(`id_menu`,`nama_menu`,`urutan`,`icon`,`newclass`) values (5,'Utility',7,'<i class=\"fa fa-pie-chart\"></i',NULL);
insert  into `r_menu`(`id_menu`,`nama_menu`,`urutan`,`icon`,`newclass`) values (6,'Mutasi Barang',4,'<i class=\"fa fa-laptop\"></i',NULL);
insert  into `r_menu`(`id_menu`,`nama_menu`,`urutan`,`icon`,`newclass`) values (7,'Biaya',5,'<i class=\"fa fa-envelope\"></i',NULL);

r_menu_sub table

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (1,'Jenis Barang',1,3,'2','','<li class=\"dropdown-header\">Referensi Produk</li>',NULL,'<i class=\"fa fa-arrow-right\"></i>','Master Jenis Barang','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (2,'Merk',1,4,'2','',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Master Merk Barang','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (5,'Pelanggan',2,1,'2','aplikasi/penjualan/v_pelanggan.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Master Pelanggan','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (6,'Penjualan',2,2,'2','aplikasi/penjualan/v_penjualan.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Transaksi Penjualan (POS)','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (7,'Retur Penjualan',2,3,'2','aplikasi/penjualan/v_retur_penjualan.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Transaksi Retur Penjualan','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (8,'Supplier',3,1,'4','aplikasi/pembelian/v_master_supplier.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Master Supplier','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (9,'Pembelian',3,2,'4','aplikasi/pembelian/v_pembelian.php',NULL,'','<i class=\"fa fa-arrow-right\"></i>','Transaksi Pembelian','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (10,'Retur Pembelian',3,3,'4','aplikasi/pembelian/v_retur_pembelian.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Transaksi Retur Pembelian','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (11,'Cetak Daftar Harga Barang',4,4,'2','aplikasi/laporan/l_daftar_harga_barang.php','',NULL,'<i class=\"fa fa-arrow-right\"></i>','Laporan Daftar Harga Barang','_blank');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (12,'Cetak Daftar Harga Jasa',4,5,'2','aplikasi/laporan/l_daftar_harga_jasa.php','',NULL,'<i class=\"fa fa-arrow-right\"></i>','Laporan Daftar Harga Jasa','_blank');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (13,'L. Pembelian',4,8,'4','aplikasi/laporan/v_laporan_pembelian.php','',NULL,'<i class=\"fa fa-arrow-right\"></i>','Laporan Pembelian','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (14,'L. Laba Rugi',4,14,'4','aplikasi/laporan/v_laporan_laba_rugi.php','<li class=\"divider\"></li>',NULL,'<i class=\"fa fa-arrow-right\"></i>','Laporan Laba Rugi','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (15,'Master Pengguna Aplikasi',5,1,'4','aplikasi/utility/v_mstuser.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Master Pengguna Aplikasi','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (16,'Referensi Sistem',5,2,'4','aplikasi/utility/v_refsystem.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Referensi Sistem','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (17,'Satuan',1,5,'2','aplikasi/master/v_satuan.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Master Satuan','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (18,'Pelunasan Jual Tempo',2,4,'2','aplikasi/penjualan/v_lunas_jual_tempo.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Form Pelunasan Penjualan Secara Tempo','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (20,'Pelunasan Beli Tempo',3,4,'4','aplikasi/pembelian/v_lunas_beli_tempo.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Form Pelunasan Pembelian Tempo','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (21,'Penyesuaian Stok',6,1,'2','aplikasi/mutasi/v_mutasi.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Menu Penyesuaian Stok (Adjustment Stok)','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (22,'Kartu Stok',6,2,'2','aplikasi/mutasi/v_kartu_stok.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Lihat Kartu Stok','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (23,'Cetak Mutasi Stok Barang',6,3,'2','aplikasi/mutasi/l_laporan_mutasi_stok.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Laporan Mutasi Stok Barang','_blank');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (24,'Cetak Barang Habis',6,4,'2','aplikasi/mutasi/l_barang_abis.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Laporan Barang Habis','_blank');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (25,'Cetak Daftar Harga Jual dan Beli',4,3,'4','aplikasi/laporan/l_daftar_seluruh_harga.php',NULL,'<li class=\"divider\"></li>','<i class=\"fa fa-arrow-right\"></i>','Laporan Daftar Harga Jual dan Beli','_blank');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (26,'L. Penjualan',4,7,'2','aplikasi/laporan/v_laporan_penjualan.php','<li class=\"divider\"></li>',NULL,'<i class=\"fa fa-arrow-right\"></i>','Laporan Penjualan','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (27,'Cetak Daftar Supplier',4,1,'4','aplikasi/laporan/l_daftar_supplier.php',NULL,'<li class=\"divider\"></li>','<i class=\"fa fa-arrow-right\"></i>','Laporan Daftar Supplier','_blank');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (28,'Cetak Daftar Pelanggan',4,2,'2','aplikasi/laporan/l_daftar_pelanggan.php',NULL,'<li class=\"divider\"></li>','<i class=\"fa fa-arrow-right\"></i>','Laporan Daftar Pelanggan','_blank');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (30,'L. Retur Penjualan',4,9,'2','aplikasi/laporan/v_laporan_retur_penjualan.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Laporan Retur Penjualan','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (31,'L. Retur Pembelian',4,10,'4','aplikasi/laporan/v_laporan_retur_pembelian.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Laporan Retur Pembelian','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (32,'Penjualan Grosir',2,5,'2','aplikasi/penjualan/v_penjualan_grosir.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Transaksi Penjualan Grosir','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (33,'Backup Database',5,3,'4','aplikasi/utility/v_backup.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Menu Backup Database','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (34,'Closing Stok',6,5,'4','aplikasi/mutasi/v_close_stok.php','<li class=\"divider\"></li>',NULL,'<i class=\"fa fa-arrow-right\"></i>','Menu Penutupan Stok (Closing Stok)','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (35,'Ubah Margin Manual',5,4,'4','aplikasi/utility/v_ubah_margin.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Menu Ubah Laba Rugi secara Manual Pada Transaksi Penjualan','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (36,'Biaya Harian',7,1,'2','aplikasi/biaya/v_biaya.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Untuk mencatat pengeluaran harian','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (37,'Setoran',7,2,'2','aplikasi/biaya/v_setoran.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Untuk mencatat setoran ','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (38,'Upah Karyawan',7,3,'4','aplikasi/biaya/v_upah.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Untuk mencatat pengeluaran gaji karyawan','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (39,'L. Biaya/Pengeluaran Harian',4,11,'2','aplikasi/laporan/v_laporan_biaya.php','<li class=\"divider\"></li>',NULL,'<i class=\"fa fa-arrow-right\"></i>','Laporan Biaya / pengeluaran harian','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (41,'L. Setoran',4,12,'2','aplikasi/laporan/v_laporan_setoran.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Laporan Setoran','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (42,'L. Upah Karyawan',4,13,'4','aplikasi/laporan/v_laporan_upah.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Laporan upah karyawan','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (43,'L. Transaksi Harian',4,6,'2','aplikasi/laporan/v_transaksi_harian.php','<li class=\"divider\"></li>','','<i class=\"fa fa-arrow-right\"></i>','Laporan transaksi harian','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (44,'Restore Master Barang',5,5,'4','aplikasi/utility/v_restore_m_barang.php','<li class=\"divider\"></li>',NULL,'<i class=\"fa fa-arrow-right\"></i>','Restoring Master Barang yang dihapus','_self');
insert  into `r_menu_sub`(`id_sub_menu`,`nama_sub_menu`,`id_menu`,`urutan_sub_menu`,`hak_akses`,`url`,`content_before`,`content_after`,`icon`,`title`,`target`) values (45,'Restore Master Jasa',5,6,'4','aplikasi/utility/v_restore_m_jasa.php',NULL,NULL,'<i class=\"fa fa-arrow-right\"></i>','Restoring Master Jasa yang dihapus','_self');

r_menu_sub_level_2 table

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

1
2
3
4
5
6
insert  into `r_menu_sub_level_2`(`id_sub_menu_level_2`,`nama_sub_menu_level_2`,`id_sub_menu`,`urutan_sub_menu`,`url`,`icon`,`title`,`target`) values (1,'multilevel 1',1,1,'aplikasi/master/v_jenis_produk.php','<i class=\"fa fa-circle\"></i>','this is multilevel','_self');
insert  into `r_menu_sub_level_2`(`id_sub_menu_level_2`,`nama_sub_menu_level_2`,`id_sub_menu`,`urutan_sub_menu`,`url`,`icon`,`title`,`target`) values (2,'multilevel 2',1,2,'aplikasi/master/v_merk.php','<i class=\"fa fa-circle\"></i>','this is multilevel','_self');
insert  into `r_menu_sub_level_2`(`id_sub_menu_level_2`,`nama_sub_menu_level_2`,`id_sub_menu`,`urutan_sub_menu`,`url`,`icon`,`title`,`target`) values (3,'multilevel 3',1,3,'aplikasi/master/v_jasa.php','<i class=\"fa fa-circle\"></i>','this is multilevel','_self');
insert  into `r_menu_sub_level_2`(`id_sub_menu_level_2`,`nama_sub_menu_level_2`,`id_sub_menu`,`urutan_sub_menu`,`url`,`icon`,`title`,`target`) values (4,'multilevel 4',1,4,'aplikasi/master/v_barang.php','<i class=\"fa fa-circle\"></i>','this is multilevel','_self');
insert  into `r_menu_sub_level_2`(`id_sub_menu_level_2`,`nama_sub_menu_level_2`,`id_sub_menu`,`urutan_sub_menu`,`url`,`icon`,`title`,`target`) values (5,'multilevel 5',2,2,'aplikasi/penjualan/v_pelanggan.php','<i class=\"fa fa-circle\"></i>','this is multilevel','_self');
insert  into `r_menu_sub_level_2`(`id_sub_menu_level_2`,`nama_sub_menu_level_2`,`id_sub_menu`,`urutan_sub_menu`,`url`,`icon`,`title`,`target`) values (6,'multilevel 6',2,1,'aplikasi/penjualan/v_penjualan.php','<i class=\"fa fa-circle\"></i>','this is multilevel','_self');

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

1
2
3
4
5
<?php class dbconn { public $dblocal; public function __construct() { } public function initDBO() { $this->dblocal = new PDO("mysql:host=localhost;dbname=dbmenu;charset=latin1","root","123456",array(PDO::ATTR_PERSISTENT => true));
$this->dblocal->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
}
}
?>

Description :

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

1
PDO("mysql:host=localhost;dbname=dbmenu;charset=latin1","your-database-user","your-database-password",array(PDO::ATTR_PERSISTENT => true))

sql.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php class sql extends dbconn { public function __construct() { $this->initDBO();
     }
      public function getMenu()
      {
           $db = $this->dblocal;
           try
           {
            $stmt = $db->prepare("select * from r_menu order by urutan");
            $stmt->execute();
            $stat[0] = true;
            $stat[1] = $stmt->fetchAll(PDO::FETCH_ASSOC);
            return $stat;
          }
          catch(PDOException $ex)
          {
            $stat[0] = false;
            $stat[1] = $ex->getMessage();
            return $stat;
          }
      }
      public function getSubMenu($id)
      {
          $db = $this->dblocal;
          try
          {
            $stmt = $db->prepare("select * from r_menu_sub where id_menu = :id order by urutan_sub_menu asc");
            $stmt->bindParam("id",$id);
            $stmt->execute();
            $stat[0] = true;
            $stat[1] = $stmt->fetchAll(PDO::FETCH_ASSOC);
            return $stat;
          }
          catch(PDOException $ex)
          {
            $stat[0] = false;
            $stat[1] = $ex->getMessage();
            return $stat;
          }
      }
      public function getSubMenuLevel2($id)
      {
          $db = $this->dblocal;
          try
          {
            $stmt = $db->prepare("select * from r_menu_sub_level_2 where id_sub_menu = :id order by urutan_sub_menu asc");
            $stmt->bindParam("id",$id);
            $stmt->execute();
            $stat[0] = true;
            $stat[1] = $stmt->fetchAll(PDO::FETCH_ASSOC);
            return $stat;
          }
          catch(PDOException $ex)
          {
            $stat[0] = false;
            $stat[1] = $ex->getMessage();
            return $stat;
          }
      }
}
 
?>

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!-- sidebar menu: : style can be found in sidebar.less -->
      
 
<ul class="sidebar-menu">
        
 
<li class="header">MAIN NAVIGATION</li>
 
 
        <?php require_once("model/dbconn.php"); require_once("model/sql.php"); $query = new sql(); $data = $query->getMenu();
          $key = $data[1];
          foreach($key as $menu)
          {
        ?>
          
 
<li class="treeview">
           <a href="#">
             <?php echo $menu['icon']?> <span><?php echo $menu['nama_menu'];?></span>
             <span class="pull-right-container">
             <i class="fa fa-angle-left pull-right"></i>
             </span>
           </a>
           <?php $sub_menu = $query->getSubMenu($menu['id_menu']);
               $count_submenu = count($sub_menu[1]);
               if($count_submenu >=1)
               {
               ?>
 
 
<ul class="treeview-menu <?php echo $menu['newclass'];?>">
               <?php foreach ($sub_menu[1] as $key ) { ?>
              
 
<li>
               <?php $sub_menu_level_2 = $query->getSubMenuLevel2($key['id_sub_menu']);
               $count_submenu_level_2 = count($sub_menu_level_2[1]);
               ?>
               <a href="<?php echo $key['url']; ?>" target="<?php echo $var['target']; ?>" title="<?php echo $key['title']; ?>">
                        <?php echo $key['icon'].$key['nama_sub_menu']; ?>
                        <?php if($count_submenu_level_2 >=1)
               {
           ?>
                        <span class="pull-right-container">
             <i class="fa fa-angle-left pull-right"></i>
             </span>
        <?php } ?>
                    </a>
                    <?php if($count_submenu_level_2 >=1)
               {
            ?>
 
 
<ul class="treeview-menu">
               <?php foreach ($sub_menu_level_2[1] as $var ) { ?>
              
 
<li>
               <a href="<?php echo $var['url']; ?>" title="<?php echo $var['title']; ?>" target="<?php echo $var['target']; ?>" >
                        <?php echo $var['icon'].$var['nama_sub_menu_level_2']; ?>
                    </a>
               </li>
 
 
               <?php } ?>
           </ul>
 
 
               <?php } ?>
               </li>
 
 
               <?php } ?>
           </ul>
 
 
               <?php } ?>
          
         </li>
 
 
        <?php } ?>
        
      </ul>

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.

[sociallocker id=”58″]

Url : http://www.mediafire.com/file/v7m8qt0yq4u0wl7/dynamic_menu_sidebar_adminlte.zip
Password : seegatesite.com

[/sociallocker]

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

Another PHP Related Post :

  • Tutorial Create Simple POS Using ReactJS And Laravel Lumen Part 1
  • How To Replace String With Another String In PHP
  • Login Page – Tutorial CRUD Client and API Server Using JQuery And Lumen Part 2
  • Tutorial CRUD Client and API Server Using JQuery And Lumen Part 1
  • How To Solve Problems Illegal mix of collations (latin1_swedish_ci,IMPLICIT) In Laravel
  • How To Resolve No ‘Access-Control-Allow-Origin’ Header In Lumen

Avatar for Sigit Prasetya Nugroho

About Sigit Prasetya Nugroho

This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.

Reader Interactions

Comments

  1. Avatar for mountainmountain says

    June 6, 2019 at 12:01 pm

    Password isnt working i.e. “seegatesite.com” Please send a new one or the files instead.

    Reply
    • Avatar for Sigit Prasetya NugrohoSigit Prasetya Nugroho says

      June 9, 2019 at 7:03 am

      hello, You typed the wrong password. Its working : seegatesite.com

      Reply
  2. Avatar for nikoniko says

    September 27, 2019 at 6:54 am

    i am already share and like on twitter but your button still close

    Reply
    • Avatar for Sigit Prasetya NugrohoSigit Prasetya Nugroho says

      September 27, 2019 at 7:04 am

      http://www.mediafire.com/file/v7m8qt0yq4u0wl7/dynamic_menu_sidebar_adminlte.zip/file

      password : seegatesite.com

      Reply
  3. Avatar for nikoniko says

    September 27, 2019 at 10:11 am

    ok thks, good job

    Reply
  4. Avatar for nikoniko says

    September 30, 2019 at 11:36 am

    i try for 3 level is running in admin lte , for 4 level i add sub_menu_level_4 table, and running in standard mode not use admin lte, after i copy paste to admin lte, for level 4 not running, can you explain to me, or can you give me source for 4 level

    Reply
    • Avatar for Sigit Prasetya NugrohoSigit Prasetya Nugroho says

      October 3, 2019 at 2:07 pm

      sorry I have never made it to 4 levels 🙂

      Reply
  5. Avatar for MarianaMariana says

    February 2, 2021 at 7:48 pm

    Hello, thanks for your contribution. How to do so that the menu and submenu links can be displayed on the same page without losing the menu, that is, without opening a new page

    Reply
    • Avatar for Sigit Prasetya NugrohoSigit Prasetya Nugroho says

      February 15, 2021 at 2:11 pm

      you can learn SPA (Single Page Application) like ReactJS , Angular Or Vue. I have several Reactjs tutorials which can be read here tutoral ReactJS for Beginners

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Welcome to my Home,

Avatar for Sigit Prasetya NugrohoThis site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.



Popular Articles

Checked checkbox AdminLTE Bootstrap in Jquery

November 4, 2014 By Sigit Prasetya Nugroho 7 Comments

Simple create date format validation with jqueryUI

December 21, 2014 By Sigit Prasetya Nugroho Leave a Comment

Create Simple Progress Bar for Fake Online Generator with Jquery

January 10, 2015 By Sigit Prasetya Nugroho Leave a Comment

22+ Coolest Free Jquery Plugin For Premium Theme

October 3, 2015 By Sigit Prasetya Nugroho Leave a Comment

Easy Build Your Anti Copy Paste Plugin

October 6, 2015 By Sigit Prasetya Nugroho Leave a Comment

Popular Tags

adminlte (15) adsense (13) adsense tips (4) affiliate amazon (13) amazon (12) Android (8) angular (16) angular 4 (12) angular 5 (4) asin grabber (3) Bootstrap (27) codeigniter (5) create wordpress theme (5) crud (8) css (6) free wordpress theme (7) google adsense (4) imacros (4) increase traffic (6) jquery (34) laravel (10) laravel 5 (5) learn android (5) lumen api (4) modal dialog (5) mysql (6) nodeJs (4) optimize seo (4) pdo (6) php (30) plugin (53) pos (8) Publisher Tips (5) react (6) Reactjs (9) SEO (37) theme (17) tutorial angular (5) tutorial angular 4 (6) tutorial javascript (10) tutorial javascript beginners (4) twitter (3) wordpress (18) wordpress plugin (13) XMLRPC (5)




  • About
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms and Conditions

©2022 Seegatesite.com