<?php include('includes/config.php'); if (isset($_GET['id'])) { $sql = "DELETE FROM `dogs` WHERE id = '".$_GET['id']."'"; $result = mysqli_query($conn, $sql); if(mysqli_affected_rows($conn)>=0){ header('Location:page5.php'); }else{ echo mysqli_error($conn); } mysqli_close($conn); } ?> <?php include('layouts/header.php'); ?> <div class="container"> <p class="text-right my-3"> <a href="createDog.php" role="button" class="btn btn-sm btn-info" name="button">เพิ่มข้อมูลสุนัข</a> </p> <table class="table table-bordered"> <thead> <tr> <th scope="col" class="text-center"></th> <th scope="col" class="text-center">สายพันธุ์</th> <th scope="col" class="text-center">ช่วงอายุ</th> <th scope="col" class="text-center">จัดการ</th> </tr> </thead> <tbody> <?php $sql = "select * from dogs"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) {?> <tr> <td class="text-center"><img src="<?= $row['picture'] ?>" alt="" width="200px"></td> <td class="text-center"><?= $row['breed'] ?></td> <td class="text-center"><?= $row['age'] ?></td> <td class="text-center"> <a href="editDog.php?id=<?= $row['id'] ?>" role="button" class="btn btn-sm btn-warning" name="button">เเก้ไข</a> <a href="page5.php?id=<?= $row['id'] ?>" role="button" class="btn btn-sm btn-danger" name="button">ลบ</a> </td> </tr> <?php } } mysqli_close($conn); ?> <!-- <tr> <td>Mark</td> <td>Otto</td> <td>@mdo</td> </tr> --> </tbody> </table> </div> <?php include('layouts/footer.php'); ?>