markleyco23

Untitled

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