-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenus.php
More file actions
62 lines (53 loc) · 1.76 KB
/
menus.php
File metadata and controls
62 lines (53 loc) · 1.76 KB
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
<?php
function category($conn,$parent_id=0, $sub_menu=''){
$dropdown = $dropdown_toggle = '';
if($sub_menu == true)
{
$dropdown = 'dropdown';
$dropdown_toggle = 'dropdown-toggle';
}
$categories = "select * from categories where status=1 and parent_id =".$parent_id;
$catp=mysqli_query($conn,$categories);
while ($cat = mysqli_fetch_assoc($catp))
{
set_html($conn,$cat, $dropdown, $dropdown_toggle);
}
}
function check_child_category($conn,$parent_id){
$categories = "select COUNT(*) AS total from categories where status=1 and parent_id =".$parent_id;
$catp=mysqli_query($conn,$categories);
$count = mysqli_fetch_array($catp);
return $count['total'];
}
function set_html($conn,$cat, $dropdown, $dropdown_toggle)
{
if( check_child_category($conn,$cat['id'])>0){
$dropdown = 'dropdown';
$dropdown_toggle = 'dropdown-toggle';
}
else{
$dropdown_toggle = '';
}
?>
<li class="nav-item <?=$dropdown?>" >
<a class="nav-link <?=$dropdown_toggle?>" href="<?=$cat['link']?>" id="navbarDropdown" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><?=$cat['display_name']?> <span class="sr-only"></span></a>
<?php
if( check_child_category($conn,$cat['catagory_id'])>0)
{
?>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<?php
category($conn,$cat['id'], true);
?>
</ul>
<?php
}
?>
</li>
<?php
}
?>
<?php
category($conn);
?>