Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Reservations database access</title>
- </head>
- <body>
- <h2>
- Welcome to the Reservations database access!
- </h2>
- <h3>
- Please click the button below to view database of customers who have made reservations.
- </h3>
- <input type="button" name="button" value="Access database">
- <?php
- echo "<table style='border: solid 1px black;'>";
- echo "<tr><th>Customer name</th><th>Customer ID</th><th>Customer email address</th><th>Reservation</th>
- <th>Event type</th><th>Event appointment date</th><th>Customer Account Records</th></tr>";
- class TableRows extends RecursiveIteratorIterator {
- function __construct($it) {
- parent::__construct($it, self::LEAVES_ONLY);
- }
- function current() {
- return "<td style='width: 150px; border: 1px solid black;'>" . parent::current(). "</td>";
- }
- function beginChildren() {
- echo "<tr>";
- }
- function endChildren() {
- echo "</tr>" . "n";
- }
- }
- $servername = "sql1.njit.edu";
- $username = "rkl9";
- $password = "teeing46";
- $dbname = "rkl9";
- try {
- $conn = new PDO("mysql:host=$sql1.njit.edu; dbname=$rkl9", $rkl9, $teeing46);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $stmt = $conn->prepare("SELECT * FROM Customer_Records");
- $stmt->execute();
- // set the resulting array to associative
- $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
- foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
- echo $v;
- }
- }
- catch(PDOException $e) {
- echo "Error: " . $e->getMessage();
- }
- $conn = null;
- echo "</table>";
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment