Foppe Hemminga 6 éve
szülő
commit
10969cd9f6
1 módosított fájl, 31 hozzáadás és 1 törlés
  1. 31 1
      index.php

+ 31 - 1
index.php

@@ -24,7 +24,37 @@
 		if($conn){
 			echo "Connected to the <strong>$db</strong> database successfully!";
 		}
-	}catch (PDOException $e){
+
+		$query = sprintf("SELECT * FROM horses 
+            WHERE race_date >= %s
+            ORDER BY race_date, venue, race;", $conn->quote(date("Y-m-d")));
+		$stmt = $conn->query($query);
+		// $r = $stmt->fetch(PDO::FETCH_ASSOC);
+    ?>
+    <table class="table table-striped table-bordered" style="width:600px;">
+        <thead>
+        <tr>
+            <th>id</th>
+            <th>venue</th>
+            <th>race_date</th>
+            <th>race</th>
+            <th>horse</th>
+        </tr>
+        </thead>
+        <tbody>
+    <?php while($row = $stmt->fetch(PDO::FETCH_ASSOC)) : ?>
+    <tr>
+        <td><?php echo htmlspecialchars($row['id']); ?></td>
+        <td><?php echo htmlspecialchars($row['venue']); ?></td>
+        <td><?php echo htmlspecialchars($row['race_date']); ?></td>
+        <td><?php echo htmlspecialchars($row['race']); ?></td>
+        <td><?php echo htmlspecialchars($row['horse']); ?></td>
+    </tr>
+	<?php endwhile; ?>
+        </tbody>
+    </table>
+    <?php
+    }catch (PDOException $e){
 		// report error message
 		echo $e->getMessage();
 	}