Advertisement
markleyco23

Untitled

Nov 18th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 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. $update = true;
  6. $record = mysqli_query($db, "SELECT * FROM info WHERE id=$id");
  7.  
  8. if (count($record) == 0 ) {
  9. $n = mysqli_fetch_array($record);
  10. $name = $n['name'];
  11. $address = $n['address'];
  12. }
  13. }
  14. ?>
  15.  
  16. <!doctype html>
  17. <html>
  18. <head>
  19. <TITLE>CRUD</TITLE>
  20. <link rel="stylesheet" type"text/css" href="style.css">
  21. </head>
  22. <body>
  23. <?php if (isset($_SESSION['message'])): ?>
  24. <div class="msg">
  25. <?php
  26. echo $_SESSION['message'];
  27. unset($_SESSION['message']);
  28. ?>
  29. </div>
  30. <?php endif ?>
  31. <table>
  32. <thead>
  33. <tr>
  34. <th>name</th>
  35. <th>Address</th>
  36. <th colspan="2">ACTION</th>
  37. </tr>
  38. </thead>
  39. <?php while ($row = mysqli_fetch_array($results)) { ?>
  40. <tr>
  41. <td><?php echo $row['name']; ?></td>
  42. <td><?php echo $row['address']; ?></td>
  43. <td>
  44. <a class="edit_btn" href="index.php?edit=<?php echo $row['id']; ?>">Edit</a>
  45. </td>
  46. <td>
  47. <a class="del_btn" href="server.php?del=<?php echo $row['id']; ?>">Delete</a>
  48. </td>
  49. </tr >
  50. <?php } ?>
  51. </tbody>
  52. </table>
  53. <form method="post" action="server.php">
  54. <input type="hidden" name="id" value="<?php echo $id; ?>">
  55. </div>
  56. <div class="input-group">
  57. <label>Name</label>
  58. <input type="text" name="name" value="<?php echo $name; ?>">
  59. </div>
  60. <div class="input-group">
  61. <label>Address</label>
  62. <input type="text" name="address" value="<?php echo $address; ?>">
  63. </div>
  64. <div class="input-group">
  65. <?php if ($update == false): ?>
  66. <button class="btn" type="submit" name="save" >Save</button>
  67. <?php else: ?>
  68. <button class="btn" type="submit" name="update" >update</button>
  69. <?php endif ?>
  70. </div>
  71. </form>
  72.  
  73. </body>
  74. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement