Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <?php
- session_start();
- if(isset($_SESSION['status']) && $_SESSION['type']==="coach") {
- echo "<br>currently logged in: " . $_SESSION["name"] . ".<br>";
- }
- else
- {
- session_destroy();
- header("Location: runnerLoginForm.html");
- }
- ?>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Untitled Document</title>
- </head>
- <body>
- <style>
- .content {
- margin: auto;
- }
- body, html {
- height: 100%;
- background-color: azure;
- font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
- text-align: center;
- }
- div {
- border: 1px solid gray;
- padding: 8px;
- }
- h1 {
- text-align: center;
- text-transform: uppercase;
- color: #4CAF50;
- letter-spacing: 10px;
- text-size: 20px;
- }
- p {
- text-align: center;
- letter-spacing: 3px;
- }
- td, th {
- border: 1px solid green;
- padding: 0.5rem;
- text-align: center;
- }
- table {
- border-collapse: collapse;
- text-align: center;
- }
- a:link, a:visited {
- background-color: #4CAF50;
- color: white;
- padding: 14px 25px;
- text-align: center;
- text-decoration: none;
- display: inline-block;
- }
- a:hover, a:active {
- background-color: #4CAF50;
- }
- </style>
- </style>
- <h1>XC Attendance
- </h1>
- <h2>Roster</h2>
- <p>
- <a href="coachHome.php">Roster</a>
- <a href="coachUnreviewedAbsences.php">Unreviewed Absences</a>
- <a href="coachReviewedAbsences.php">Reviewed Absences</a>
- <a href="coachHome.php?hello=true">Logout</a>
- </p>
- <br>
- <?php
- function logout() {
- session_destroy();
- //echo "refreshing";
- header("Location: runnerLoginForm.html");
- }
- if (isset($_GET['hello']))
- {
- logout();
- //setcookie("user", "", time() - 3600);
- }
- echo "<table align='center'>";
- echo "<tr><th>id</th><th>name</th><th># of excused</th><th># of unexcused</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 green;'>" . parent::current() . "</td>";
- }
- function beginChildren()
- {
- echo "<tr>";
- }
- function endChildren()
- {
- echo "</tr>" . "\n";
- }
- }
- $servername = "localhost";
- $username = "playground18";
- $password = "Cdz5SOVrY2p8fnWS";
- $dbname = "playground18";
- try
- {
- $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $stmt = $conn->prepare("SELECT * ");
- // $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;
- }
- */
- $stmt = $conn->prepare("SELECT id, name, excused_absences, unexcused_absences FROM tanay_xcatt_runners WHERE id>10");
- $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>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement