<!-- Step-1 : Make Connection and Fetch Data --> <!-- Step-2 : condition check if any row contain any data --> <!-- Step-3 : insert data into table using loops --> <!-- Step-4 : role comes in 0 & 1 format, use if contion for changing them --> <!-- Step-5 : use php echo $row["user_id"] for sending data to update and delete page --> <?php include "header.php"; ?> <div id="admin-content"> <div class="container"> <div class="row"> <div class="col-md-10"> <h1 class="admin-heading">All Users</h1> </div> <div class="col-md-2"> <a class="add-new" href="add-user.php">add user</a> </div> <div class="col-md-12"> <!-- Step-1 : Make Connection and Fetch Data --> <?php include "config.php"; $sql = "SELECT * FROM user ORDER BY user_id DESC"; $result = mysqli_query($conn, $sql) or die("Query Failed."); /*-- Step-2 : condition check if any row contain any data */ if(mysqli_num_rows($result) > 0){ ?> <table class="content-table"> <thead> <th>S.No.</th> <th>Full Name</th> <th>User Name</th> <th>Role</th> <th>Edit</th> <th>Delete</th> </thead> <tbody> <!-- Step-3 : insert data into table using loops --> <?php while($row = mysqli_fetch_assoc($result)) { ?> <tr> <td class='id' ><?php echo $row['user_id']; ?></td> <td><?php echo $row['first_name'] . " ". $row['last_name']; ?></td> <td><?php echo $row['username']; ?></td> <td><?php /*-- Step-4 : role comes in 0 & 1 format, use if contion for changing them */ if($row['role'] == 1){ echo "Admin"; }else{ echo "Normal"; } ?></td> <!-- Step-5 : use php echo $row["user_id"] for sending data to update and delete page --> <td class='edit'><a href='update-user.php?id=<?php echo $row["user_id"];?>' ><i class='fa fa-edit'></i></a></td> <td class='delete'><a href='delete-user.php?id=<?php echo $row["user_id"];?>' ><i class='fa fa-trash-o'></i></a></td> </tr> <?php } ?> </tbody> </table> <?php } ?> <ul class='pagination admin-pagination'> <li class="active"><a>1</a></li> <li><a>2</a></li> <li><a>3</a></li> </ul> </div> </div> </div> </div> <?php include "header.php"; ?>