A simple php website which displays quotes on pictures of pandas.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.6 KiB

  1. <?php
  2. require_once 'includes/carbon.php';
  3. use Carbon\Carbon;
  4. if($loggedIn)
  5. {
  6. if(isset($_POST['del_quote_id']))
  7. {
  8. $del_id = mysqli_real_escape_string($dbc, trim($_POST['del_quote_id']));
  9. $q = "delete from quote where quote_id='$del_id' limit 1";
  10. $r = mysqli_query($dbc, $q);
  11. header("Location: quotes.php");
  12. }
  13. echo '<h1 class="w3-text-teal w3-center">Quotes</h1>';
  14. $q = "select * from quote";
  15. $r = mysqli_query($dbc, $q);
  16. echo '<div class="w3-responsive w3-card-4">
  17. <table class="w3-table w3-striped w3-bordered">
  18. <thead>
  19. <tr class="w3-theme w3-center">
  20. <td>Quote</td>
  21. <td>Person</td>
  22. <td>Created By</td>
  23. <td>Date</td>
  24. <td>Delete</td>
  25. </tr>
  26. </thead>
  27. <tbody>
  28. ';
  29. while($row = mysqli_fetch_array($r))
  30. {
  31. echo '<tr>';
  32. //quote
  33. echo "<td>" . $row['quote'] . "</td>";
  34. //person
  35. $q2 = "select name from people where person_id='" . $row['person_id'] . "'";
  36. $r2 = mysqli_query($dbc, $q2);
  37. while($row2 = mysqli_fetch_array($r2))
  38. {
  39. echo "<td>" . $row2['name'] . "</td>";
  40. }
  41. //created by
  42. $q2 = "select user_name from users where user_id='" . $row['user_id'] . "'";
  43. $r2 = mysqli_query($dbc, $q2);
  44. while($row2 = mysqli_fetch_array($r2))
  45. {
  46. echo "<td>" . $row2['user_name'] . "</td>";
  47. }
  48. //date
  49. $c = Carbon::createFromTimestampUTC(strtotime($row['creation_date'] . ' UTC'));
  50. echo '<td>' . $c->format('l jS \of F Y') . '</td>';
  51. //del
  52. echo '<td>';
  53. echo '<form action = "quotes.php" method = "post">
  54. <input type = "submit" name="Delete" value="Delete" class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align"/>
  55. <input type="hidden" name="delPerson" value="TRUE">
  56. <input type="hidden" name="del_quote_id" value=' . $row['quote_id'] . '>
  57. </form>';
  58. echo '</td>';
  59. echo '</tr>';
  60. }
  61. echo '</tbody>
  62. </table>
  63. </div>';
  64. }
  65. ?>