I have created a page in php which allows the users to update,create and delete the list. There are two types of users, admin and student. I want to allow the students only to view the list and allow the admin to perform other operation. I have created the table to view the actions. How can I separate it for different users? I cannot redirect the users based upon their role because user needs to click button to perform action.
<?php
include 'Database.php';
$query=mysqli_query($con,"SELECT * FROM student");
while ($res=mysqli_fetch_array($query)) {
?>
<tr>
<td><?php echo $res['id']; ?></td>
<td><?php echo $res['Username']; ?></td>
<td><?php echo $res['Email']; ?></td>
<td><?php echo $res['Course']; ?></td>
<td> <button class="w3-btn w3-red"> <a href="delete.php?id=<?php echo $res['id']; ?>"> Delete </a> </button>
<button class="w3-btn w3-blue"> <a href="update.php?id=<?php echo $res['id']; ?>"> Update </a> </button> </td>
</tr>
<?php
}
?>
</table>
</body>
</html>