Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <table class="table table-bordered table-hover">
- <thead>
- <tr>
- <th>ID</th>
- <th>Avatar<th>
- <th>Username</th>
- <th>Full name</th>
- <th>Email</th>
- <th>Registered on</th>
- <th>Role</th>
- </tr>
- </thead>
- <tbody>
- <?php
- $sql = "SELECT id, username, email, firstname, lastname, registration_date, role, avatar FROM users ORDER BY id DESC";
- $query = mysqli_query($connection, $sql);
- if(!$query) {
- echo "Cannot get users from the database. " . mysqli_error($connection);
- }
- while($row = mysqli_fetch_assoc($query)) {
- $id = $row['id'];
- $username = $row['username'];
- $email = $row['email'];
- $firstname = $row['firstname'];
- $lastname = $row['lastname'];
- $date = $row['registration_date'];
- $role = $row['role'];
- $avatar = $row['avatar'];
- ?>
- <tr>
- <td><?= $id ?></td>
- <td><img class="img-responsive" style="max-width: 65px; max-height: 65px;" src="../images/<?= $avatar ?>"></td>
- <td><?= $username ?></td>
- <td><?= $firstname . " " . $lastname ?></td>
- <td><?= $email ?></td>
- <td><?= $date ?></td>
- <td><?= $role ?></td>
- <td><a href="users.php?source=update_user&user_id=<?= $id ?>">Update</a></td>
- <td><a href="users.php?delete_user=<?= $id ?>">Delete</a></td>
- </tr>
- <?php
- }
- ?>
- </tbody>
- </table>
- <?php
- if(isset($_GET['delete_user'])) {
- $user_id = $_GET['delete_user'];
- $sql = "DELETE FROM users WHERE id = " . $post_id;
- $query = mysqli_query($connection, $sql);
- if(!$query) {
- echo 'Cannot remove user from the database. ' . mysqli_error($connection);
- }
- header("Location: users.php");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement