Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- $dbhost = "localhost";
- $dbname = "sportsDay";
- $dbuser = "root";
- $dbpass = "ITGS!!!";
- $conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $conn->exec("SET CHARACTER SET utf8mb4");
- $result[]=0;
- foreach ($event as $e) {
- foreach ($gender as $g) {
- foreach ($year as $y) {
- $sql = "SELECT Students.lName, Students.fName, Students.house
- FROM Entries INNER JOIN Events ON Entries.ev1ID = Events.ID
- JOIN Students ON Students.stID = Entries.stID
- WHERE (Entries.ev1ID = :event or Entries.ev2ID = :event2) and (Students.year = :year)
- AND (Students.gender = :gender)
- ORDER BY Students.house ASC"; // Query stays the same.
- $stmt->bindValue(':event', $e);
- $stmt->bindValue(':event2', $e);
- $stmt->bindValue(':year', $y);
- $stmt->bindValue(':gender', $g);
- // Use $e, $g and $y for your query and table construction.
- $result[]=0;
- try
- {
- $stmt = $conn->prepare($sql);
- $stmt->bindValue(':event', $e);
- $stmt->bindValue(':event2', $e);
- $stmt->bindValue(':year', $y);
- $stmt->bindValue(':gender', $g);
- $stmt->execute();
- $result = $stmt->fetchAll();
- $count = $stmt->rowCount();
- }
- catch(PDOException $e)
- {
- echo $e->getMessage();
- }
- ?>
- <html>
- <head>
- <style type="text/css">
- table{
- width: 85%;
- margin-left: 2%;
- }
- th, td{
- padding: 5px 25px 5px 25px;
- }
- </style>
- <body>
- <?php if ($count > 0): ?>
- <table border="1" >
- <tr>
- <th>Name</th>
- <th>House</th>
- <th>Score</th>
- </tr>
- <?php foreach ($result as $row) {
- ?>
- <tr>
- <td><?php echo $row['fName']. ' '.$row['lName'] ?></td>
- <td><?php echo $row['house'] ?></td> <td></td>
- </tr>
- <?php } ?>
- </table>
- <?php else: echo "No results.";
- endif;
- }
- }
- } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement