-
Notifications
You must be signed in to change notification settings - Fork 0
/
trainlist.php
32 lines (28 loc) · 940 Bytes
/
trainlist.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
include_once 'dbconnection.php';
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Select all records from the TrainList table
$sql = "SELECT * FROM trainlist";
$result = mysqli_query($conn, $sql);
// Loop through the results and display them in the table
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td>" . $row["train_number"] . "</td>";
echo "<td>" . $row["train_name"] . "</td>";
echo "<td>" . $row["source"] . "</td>";
echo "<td>" . $row["destination"] . "</td>";
echo "<td>" . $row["ac_fare"] . "</td>";
echo "<td>" . $row["general_fare"] . "</td>";
echo "<td>" . $row["available_weekdays"] . "</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='6'>No trains found</td></tr>";
}
// Close the connection
//mysqli_close($conn);
?>