Here I have a navbar.php file where I'm calling it to different dashboard according to user role and I'm differentiating by using a flag in my db table. i.e., flag = 0 and flag = 1.
Below is my navbar.php code
<?php
include('db.php');
date_default_timezone_set('Asia/Calcutta');
$sql = "SELECT * FROM login";
$stmt = $db->prepare($sql);
$stmt->execute();
$res = $stmt->fetch();
?>
<div class="sidebar" data-color="purple" data-image="assets/img/sidebar-5.jpg">
<div class="sidebar-wrapper">
<div class="logo">
<a href="#" class="simple-text">
Test
</a>
</div>
<ul class="nav">
<li class="active">
<a href="dashboard.php">
<i class="pe-7s-graph"></i>
<p>Dashboard</p>
</a>
</li>
<?php if($res["flag"] == "1"){
?>
<li>
<a href="user.html">
<i class="pe-7s-user"></i>
<p>User</p>
</a>
</li>
<li>
<a href="table.html">
<i class="pe-7s-note2"></i>
<p>List</p>
</a>
</li>
<?php } else {
?>
<li class="disable">
<a href="">
<i class="pe-7s-user"></i>
<p>User</p>
</a>
</li>
<li class="disable">
<a href="">
<i class="pe-7s-note2"></i>
<p>List</p>
</a>
</li>
<?php }?>
</ul>
</div>
As shown above. if the flag is 0(zero) also in db the first <li> is displaying. It is not going to else part <li>.
Can anyone tell me what wrong am I doing here?
Aucun commentaire:
Enregistrer un commentaire