Guest User

Untitled

a guest
Mar 6th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Reservations database access</title>
  5. </head>
  6. <body>
  7. <h2>
  8. Welcome to the Reservations database access!
  9. </h2>
  10. <h3>
  11. Please click the button below to view database of customers who have made reservations.
  12. </h3>
  13.  
  14. <input type="button" name="button" value="Access database">
  15.  
  16. <?php
  17. echo "<table style='border: solid 1px black;'>";
  18. echo "<tr><th>Customer name</th><th>Customer ID</th><th>Customer email address</th><th>Reservation</th>
  19. <th>Event type</th><th>Event appointment date</th><th>Customer Account Records</th></tr>";
  20.  
  21. class TableRows extends RecursiveIteratorIterator {
  22. function __construct($it) {
  23. parent::__construct($it, self::LEAVES_ONLY);
  24. }
  25.  
  26. function current() {
  27. return "<td style='width: 150px; border: 1px solid black;'>" . parent::current(). "</td>";
  28. }
  29.  
  30. function beginChildren() {
  31. echo "<tr>";
  32. }
  33.  
  34. function endChildren() {
  35. echo "</tr>" . "n";
  36. }
  37. }
  38.  
  39. $servername = "sql1.njit.edu";
  40. $username = "rkl9";
  41. $password = "teeing46";
  42. $dbname = "rkl9";
  43.  
  44. try {
  45. $conn = new PDO("mysql:host=$sql1.njit.edu; dbname=$rkl9", $rkl9, $teeing46);
  46. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  47. $stmt = $conn->prepare("SELECT * FROM Customer_Records");
  48. $stmt->execute();
  49.  
  50. // set the resulting array to associative
  51. $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
  52.  
  53. foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
  54. echo $v;
  55. }
  56. }
  57. catch(PDOException $e) {
  58. echo "Error: " . $e->getMessage();
  59. }
  60. $conn = null;
  61. echo "</table>";
  62. ?>
  63.  
  64. </body>
  65. </html>
Add Comment
Please, Sign In to add comment