Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['save'])){
- $checkbox = NULL;
- if (isset($_POST['check']))
- {
- $checkbox = $_POST['check'];
- }
- if (is_array($checkbox))
- {
- $checkboxCount = count($checkbox);
- for($i=0; $i < $checkboxCount; $i++)
- {
- /* IMPORTANT:
- You need to validate each $checkbox item to make sure:
- - it is a valid int number
- - the current user has permission to delete it
- */
- $del_id = $checkbox[$i];
- /* Make sure $del_id is a valid int. You should also check that is a correct database ID. */
- if (filter_var($del_id, FILTER_VALIDATE_INT))
- {
- mysqli_query($link,"DELETE FROM admin WHERE id='".mysqli_real_escape_string($link, $del_id)."'");
- }
- }
- $message = "Data deleted successfully !";
- }
- else
- {
- $message = "No data selected!";
- }
- }
- $result = mysqli_query($link,"SELECT * FROM admin LIMIT $offset,$total_records_per_page");
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
- <style><?php include 'Backend.css'; ?></style>
- <meta charset="UTF-8">
- <title>Dashboard</title>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
- <script src='https://kit.fontawesome.com/a076d05399.js'></script>
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
- </head>
- <body>
- <div><?php if(isset($message)) { echo $message; } ?>
- </div>
- <div class="container">
- <form method="post" action="admin.php">
- <table class="table table-bordered" id="myTables">
- <thead>
- <tr>
- <th><input type="checkbox" id="checkAl"> Select All</th>
- <th>Admin Id</th>
- <th>Username</th>
- <th>Email</th>
- <th>Password</th>
- <th>Action</th>
- </tr>
- </thead>
- <?php
- $i=0;
- while($row = mysqli_fetch_array($result)) {
- ?>
- <tr>
- <td><input type="checkbox" id="checkItem" name="check[]" value="<?php echo $row["id"]; ?>"></td>
- <td><?php echo $row["id"]; ?></td>
- <td><?php echo $row["username"]; ?></td>
- <td><?php echo $row["email"]; ?></td>
- <td><?php echo $row["password"]; ?></td>
- <?Php
- echo "<td>";
- echo "<a href='Admin-View.php?id=". $row['id'] ."' title='View Record' data-toggle='tooltip'><span class='glyphicon glyphicon-eye-open'></span></a>";
- echo "<a href='Admin-Update.php?id=". $row['id'] ."' title='Update Record' data-toggle='tooltip'><span class='glyphicon glyphicon-pencil'></span></a>";
- echo "<a href='Admin-Delete.php?id=". $row['id'] ."' title='Delete Record' data-toggle='tooltip'><span class='glyphicon glyphicon-trash'></span></a>";
- echo "</td>";
- ?>
- </tr>
- </div>
- </div>
- </div>
- </div>
- </div>
- <?php
- $i++;
- }
- ?>
- </table>
- <input type="submit" name="submit" value="Delete" class="btn btn-primary btn-md pull-left" onClick="return confirm('Are you sure you want to delete?');" ></td>
- </form>
- <script>
- $("#checkAl").click(function () {
- $('input:checkbox').not(this).prop('checked', this.checked);
- });
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment