-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
121 lines (121 loc) · 3.55 KB
/
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
<html>
<head>
<style>
table{
border-collapse:collapse;
width:60%;
color:#588c7e;
font-family:monospace;
font-size:20px;
text-align:center;
}
th{
background-color:#d96459;
color:white;
}
</style>
</head>
<body>
<?php
$i=0;
$source=$_GET['source'];
$des=$_GET['des'];
$con=mysqli_connect("localhost","root","","test");
$sql="SELECT count(id) as tot from route1 where stopage='$source' or stopage='$des'";
$res=mysqli_query($con,$sql);
$values=mysqli_fetch_assoc($res);
$numrow=$values['tot'];
if($numrow==2)
{
$i=1;
echo"The Bus Going from Gandhimore to Rathtala.<br>";
echo"<table border='1' >";
echo"<tr><th>Bus number</th><th>Fare</th><th>Distance</th></tr>";
$fare_src="SELECT fare from route1 where stopage='$source'";
$res_src=mysqli_query($con,$fare_src);
$val_src=mysqli_fetch_assoc($res_src);
$src_fare=$val_src["fare"];
$fare_src="SELECT fare from route1 where stopage='$des'";
$res_src=mysqli_query($con,$fare_src);
$val_src=mysqli_fetch_assoc($res_src);
$des_fare=$val_src["fare"];
$price=($des_fare-$src_fare);
$sql1="SELECT BUSID from bus where ROUTE='route1'";
$res1=mysqli_query($con,$sql1);
$distance="SELECT distance from route1 where stopage='$source'";
$res_dis=mysqli_query($con,$distance);
$val_dis=mysqli_fetch_assoc($res_dis);
$src_dis=$val_dis["distance"];
$distance="SELECT distance from route1 where stopage='$des'";
$res_dis=mysqli_query($con,$distance);
$val_dis=mysqli_fetch_assoc($res_dis);
$des_dis=$val_dis["distance"];
$distance_journey=$des_dis-$src_dis;
if($price<=2)
{
$final_price=5;
while($row=mysqli_fetch_assoc($res1))
{
echo "<tr><td>{$row['BUSID']}</td><td>{$final_price}</td><td>{$distance_journey}</td></tr>";
}
}
else if($price>2&&$price<=4)
{
$final_price=9;
while($row=mysqli_fetch_assoc($res1))
{
echo "<tr><td>{$row['BUSID']}</td><td>{$final_price}</td><td>{$distance_journey}</td></tr>";
}
}
echo"</table>";
}
$sql="SELECT count(id) as tot from route2 where stopage='$source' or stopage='$des'";
$res=mysqli_query($con,$sql);
$values=mysqli_fetch_assoc($res);
$numrow=$values['tot'];
if($numrow==2)
{
echo"The Bus Going from Gandhimore to Naihati.<br>";
echo"<table border='1'>";
echo"<tr><td>Bus number</td><td>Fare</td><td>Distance</td></tr>";
$fare_src="SELECT fare from route2 where stopage='$source'";
$res_src=mysqli_query($con,$fare_src);
$val_src=mysqli_fetch_assoc($res_src);
$src_fare=$val_src["fare"];
$fare_src="SELECT fare from route2 where stopage='$des'";
$res_src=mysqli_query($con,$fare_src);
$val_src=mysqli_fetch_assoc($res_src);
$des_fare=$val_src["fare"];
$price=($des_fare-$src_fare);
$sql1="SELECT BUSID from bus where ROUTE='route2'";
$res1=mysqli_query($con,$sql1);
$distance="SELECT distance from route2 where stopage='$source'";
$res_dis=mysqli_query($con,$distance);
$val_dis=mysqli_fetch_assoc($res_dis);
$src_dis=$val_dis["distance"];
$distance="SELECT distance from route2 where stopage='$des'";
$res_dis=mysqli_query($con,$distance);
$val_dis=mysqli_fetch_assoc($res_dis);
$des_dis=$val_dis["distance"];
$distance_journey=$des_dis-$src_dis;
if($price<=2)
{
$final_price=5;
while($row=mysqli_fetch_assoc($res1))
{
echo "<tr><td>{$row['BUSID']}</td><td>{$final_price}</td><td>{$distance_journey}</td></tr>";
}
}
else if($price>2&&$price<=4)
{
$final_price=9;
while($row=mysqli_fetch_assoc($res1))
{
echo "<tr><td>{$row['BUSID']}</td><td>{$final_price}</td><td>{$distance_journey}</td></tr>";
}
}
echo"</table>";
}
?>
</body>
</html>