<!DOCTYPE html>
<html lang="en">
<head>
  <title>ฟอร์มแก้ไขข้อมูล</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<?php
include("db.php");
$id=$_GET['id'];

$sql = "SELECT * FROM books WHERE book_id='$id' ";
$result = $conn->query($sql);
$row = $result->fetch_assoc();
//$row = $result->fetch_array();
//echo "$row";
$id=$row['book_id'];
$book_name =$row['book_name'];
$description=$row['description'];
$publisher=$row['publisher'];
$author=$row['author'];

?>
<div class="container mt-3">
  <h2>ฟอร์มแก้ไขข้อมูล</h2>
  <form action="editdata.php" method="post">
  <div class="mb-3 mt-3">
      <label for="book_name">ชื่อหนังสือ:</label>
      <input type="text" id="book_name"  class="form-control" placeholder="ป้อนชื่อ" name="book_name" value="<?=$book_name?>">
    </div>    
    <div class="mb-3 mt-3">
      <label for="description">คำอธิบาย:</label>
      <input type="text" class="form-control" id="description" placeholder="Enter description" name="description" value="<?=$description?>">
    </div>
    <div class="mb-3 mt-3">
      <label for="publisher">สำนักพิมพ์:</label>
      <input type="text" class="form-control" id="publisher" placeholder="Enter publisher" name="publisher" value="<?=$publisher?>">
    </div>
    <div class="mb-3">
      <label for="author">ผู้แต่ง:</label>
      <input type="text" class="form-control" id="author" placeholder="Enter author" name="author"value="<?=$author?>">   </div>
    <input type="hidden" value="<?=$id?>" name="id">
    <button type="submit" class="btn btn-primary">บันทึกข้อมูล</button>
  </form>
</div>

</body>
</html>