-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewRoute.php
86 lines (69 loc) · 2.28 KB
/
viewRoute.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
include 'database/init.php';
protect_page();
include('includes/header.php');
include('includes/navbar.php');
?>
<div class="container-fluid">
<!-- DataTales Example -->
<div class="card shadow mb-4" >
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary" >All the avaiable Routes!
</h6>
</div>
<div class="card-body">
<div class="table-responsive">
<?php
require("connection.php");
try {
// prepare sql and bind parameters
$stmt = $conn->prepare("SELECT *
FROM ((route
INNER JOIN train ON route.trainId = train.trainId)
INNER JOIN driver ON route.dId = driver.dId);");
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
//echo "All the records";
} catch (PDOException $e) {
echo "Error: " . $e->getMessage();
}
$conn = null;
?>
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th> Route ID </th>
<th> To </th>
<th> From </th>
<th> Departure Time </th>
<th> Arrival Time </th>
<th> Train Name </th>
<th> Driver Name </th>
</tr>
</thead>
<tbody>
<?php
foreach ($stmt->fetchAll() as $k => $row) {
?>
<tr>
<td><?php echo $row['rId']; ?></td>
<td><?php echo $row['rTo']; ?></td>
<td><?php echo $row['rFrom']; ?></td>
<td><?php echo $row['dTime']; ?></td>
<td><?php echo $row['aTime']; ?></td>
<td><?php echo $row['trainName']; ?></td>
<td><?php echo $row['dFirstName']; echo ' '; echo $row['dLastName']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- /.container-fluid -->
<?php
include('includes/scripts.php');
?>