-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathst_search.php
209 lines (180 loc) · 5.16 KB
/
st_search.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<!DOCTYPE html>
<html>
<head>
<title>Get Station Information</title>
<style>
table {
width: 100%;
border-collapse: collapse;
font-size: 30px;
display: inline-block;
padding: .25em 0;
color: black;
}
th, td {
border: 2px solid red;
text-align: left;
padding: 8px;
}
th {
background-color: transparent;
}
</style>
</head>
<body>
<style>
body{
margin: 0px;
padding: 0px;
background-image: url('train.jpg');
background-repeat: no-repeat;
}
li {
display: inline;
}
li {
float: left;
}
a {
display: block;
padding: 8px;
background-color: #dddddd;
}
ul {
background-color: #dddddd;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #dddddd;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
/* Change the link color to #111 (black) on hover */
li a:hover {
background-color: #111;
}
.heading{
color: yellow;
}
h2{
color: yellow;
}
form{
font-size: 50px;
background-image: url('indianrailway.jpg');
}
.button-9 {
appearance: button;
backface-visibility: hidden;
background-color: #405cf5;
border-radius: 6px;
border-width: 0;
box-shadow: rgba(50, 50, 93, .1) 0 0 0 1px inset,rgba(50, 50, 93, .1) 0 2px 5px 0,rgba(0, 0, 0, .07) 0 1px 1px 0;
box-sizing: border-box;
color: #fff;
cursor: pointer;
font-family: -apple-system,system-ui,"Segoe UI",Roboto,"Helvetica Neue",Ubuntu,sans-serif;
font-size: 30%;
height: 44px;
line-height: 1.15;
margin: 12px 0 0;
outline: none;
overflow: hidden;
padding: 0 25px;
position: relative;
text-align: center;
text-transform: none;
transform: translateZ(0);
transition: all .2s,box-shadow .08s ease-in;
user-select: none;
-webkit-user-select: none;
touch-action: manipulation;
width: 30%;
}
.button-9:disabled {
cursor: default;
}
.button-9:focus {
box-shadow: rgba(50, 50, 93, .1) 0 0 0 1px inset, rgba(50, 50, 93, .2) 0 6px 15px 0, rgba(0, 0, 0, .1) 0 2px 2px 0, rgba(50, 151, 211, .3) 0 0 0 4px;
}
input{
background-color: white;
border: black;
border-radius: 50px ;
width: 30%;
height: 44px;
text-align: center;
font-size: 30px;
}
</style>
<h1 class="heading">Railway Enquiry System</h1>
<ul>
<li><a href="t_search.php">Search Train</a></li>
<li><a href="st_search.php">Search station</a></li>
<li><a href="from_to.php">Search Train between two station</a></li>
<li><a href="s_bw.php" >Search Train between two station in a time slot</a></li>
</ul>
<h2 >Enter Station Code to Get Information</h2>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="text" id="station_code" name="station_code" placeholder="Enter Station Code" required><br>
<button class="button-9" type="submit">Get Information</button>
</form>
</body>
</html>
<?php
// Database connection
$servername = "localhost"; // Change this to your MySQL server name if it's different
$username = "root"; // Change this to your MySQL username
$password = ""; // Change this to your MySQL password
$dbname = "railways"; // Change this to your database name
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Check if station code is provided
if(isset($_POST['station_code'])) {
$station_code = $_POST['station_code'];
// Query to retrieve station name, station code, train no., train name, arrival, departure based on station code
$sql = "SELECT station.stationCode, station.stName, route.trainNo, train.trainName, route.arrival, route.departure
FROM station
INNER JOIN route ON station.stationCode = route.stationCode
INNER JOIN train ON route.trainNo = train.trainNo
WHERE station.stationCode = '$station_code'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// Start HTML table
echo "<table>";
echo "<tr><th>Station Code</th><th>Station Name</th><th>Train No.</th><th>Train Name</th><th>Arrival</th><th>Departure</th></tr>";
// Output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td>" . $row["stationCode"] . "</td>";
echo "<td>" . $row["stName"] . "</td>";
echo "<td>" . $row["trainNo"] . "</td>";
echo "<td>" . $row["trainName"] . "</td>";
echo "<td>" . $row["arrival"] . "</td>";
echo "<td>" . $row["departure"] . "</td>";
echo "</tr>";
}
// End HTML table
echo "</table>";
} else {
echo "No data found for the station code provided.";
}
}
// Close connection
$conn->close();
?>