Advertisement
Guest User

Untitled

a guest
Dec 9th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. <?php include('server.php');
  2. //fetch the record to be updated
  3. if (isset($_GET['edit'])) {
  4. $id = $_GET['edit'];
  5. $edit_state = true;
  6. $rec = mysqli_query($db, "SELECT * FROM info WHERE id=$id");
  7. $record = mysqli_fetch_array($rec);
  8. $title = $record['title'];
  9. $author = $record['author'];
  10. $genre = $record['genre'];
  11. $isbn = $record['isbn'];
  12. $callnumber = $record['callnumber'];
  13. $bookin = $record['bookin'];
  14. $bookout = $record['bookout'];
  15. $id = $record['id'];
  16. }
  17. ?>
  18.  
  19. <!doctype html>
  20. <html>
  21. <head>
  22. <TITLE>LIBRARY SYSTEM</TITLE>
  23. <link rel="stylesheet" type"text/css" href="style.css">
  24. </head>
  25. <body>
  26. <?php if (isset($_SESSION['msg'])): ?>
  27. <div class="msg">
  28. <?php
  29. echo $_SESSION['msg'];
  30. unset($_SESSION['msg']);
  31. ?>
  32. </div>
  33. <?php endif ?>
  34. <table>
  35. <thead>
  36. <tr>
  37. <th>Title</th>
  38. <th>Author</th>
  39. <th>Genre</th>
  40. <th>ISBN</th>
  41. <th>Call Number</th>
  42. <th>Book in</th>
  43. <th>Book out</th>
  44. <th colspan="2">ACTION</th>
  45. </tr>
  46. </thead>
  47.  
  48. <tbody>
  49. <?php while ($row = mysqli_fetch_array($results)) { ?>
  50. <tr>
  51. <td><?php echo $row['title']; ?></td>
  52. <td><?php echo $row['author']; ?></td>
  53. <td><?php echo $row['genre']; ?></td>
  54. <td><?php echo $row['isbn']; ?></td>
  55. <td><?php echo $row['callnumber']; ?></td>
  56. <td><?php echo $row['bookin']; ?></td>
  57. <td><?php echo $row['bookout']; ?></td>
  58. <td>
  59. <a class="edit_btn" href="index.php?edit=<?php echo $row['id']; ?>">Edit</a>
  60. </td>
  61. <td>
  62. <a class="del_btn" href="server.php?del=<?php echo $row['id']; ?>">Delete</a>
  63. </td>
  64. </tr >
  65. <?php } ?>
  66. </tbody>
  67. </table>
  68. <form method="post" action="server.php">
  69. <input type="hidden" name="id" value="<?php echo $id; ?>">
  70. <div class="input-group">
  71. <label>Title</label>
  72. <input type="text" name="title" value="<?php echo $title; ?>">
  73. </div>
  74. <div class="input-group">
  75. <label>Author</label>
  76. <input type="text" name="author" value="<?php echo $author; ?>">
  77. </div>
  78. <div class="input-group">
  79. <label>Genre</label>
  80. <input type="text" name="genre" value="<?php echo $genre; ?>">
  81. </div>
  82. <div class="input-group">
  83. <label>ISBN</label>
  84. <input type="text" name="isbn" value="<?php echo $isbn; ?>">
  85. </div>
  86. <div class="input-group">
  87. <label>Call Number</label>
  88. <input type="text" name="callnumber" value="<?php echo $callnumber; ?>">
  89. </div>
  90. <div class="input-group">
  91. <label>Book in</label>
  92. <input type="text" name="bookin" value="<?php echo $bookin; ?>">
  93. </div>
  94. <div class="input-group">
  95. <label>Book out</label>
  96. <input type="text" name="bookout" value="<?php echo $bookout; ?>">
  97. </div>
  98. <div class="input-group">
  99. <?php if ($edit_state == false): ?>
  100. <button type="submit" name="save" class="btn">Save</button>
  101. <?php else: ?>
  102. <button type="submit" name="update" class="btn">Update</button>
  103. <?php endif ?>
  104. </div>
  105. </form>
  106.  
  107. </body>
  108. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement