0

我创建了巴士路线的搜索功能。我创建了一个索引页面:

<DOCTYPE! html>
<head>
<title>Search</title>
<body>
Enter info below:
<br />
<form action='routes.php' action='get'>

Start Destination:
<select name="start">
 <option value="StopA">Stop A</option>  
</select>
<br />
End Destination:
<select name="stop">
 <option value="StopZ">Stop Z</option>
</select>

Departing between (start):
<select name="start_time">
 <option value="13:40">13:40</option>
 <option value="13:45">13:45</option>
 <option value="13:50">13:50</option>
 <option value="13:55">13:55</option>
</select>
<br />
Departing between (end):
<select name="end_time">
 <option value="13:40">13:40</option>
 <option value="13:45">13:45</option>
 <option value="13:50">13:50</option>
 <option value="13:55">13:55</option>
</select>
<input type="submit" value="Submit">
</form>

和一个连接到我的数据库的“路线”页面

<?php
mysql_connect('', '', '');
$start = $_GET['start'];
$stop = $_GET['stop'];
$start_time = $_GET['start_time'];
$end_time = $_GET['end_time'];


$query = mysql_query("SELECT * FROM searchengine.times where STOP_1 = '$start' and   STOP_7 = '$stop' and time(time) between '$start_time' and '$end_time'") or die(mysql_error());

echo "<table border='1'>";
echo "<tr> <th>Departure Time</th> <th>Route No.</th> <th>Stop 1</th> <th>Stop 2</th>       <th>Stop 3</th> <th>Stop 4</th> <th>Stop 5</th> </tr>";

while($row = mysql_fetch_array($query))
{ 
echo "<tr><td>"; 
echo $row['time'];
echo "</td><td>"; 
echo $row['route_no'];
echo "</td><td>";
echo $row['STOP_1'];
echo "</td><td>";
echo $row['STOP_2'];
echo "</td><td>";
echo $row['STOP_3'];
echo "</td><td>";
echo $row['STOP_4'];
echo "</td><td>";
echo $row['STOP_5'];
echo "</td></tr>"; 
echo $row['STOP_6'];
echo "</td></tr>";
echo $row['STOP_7'];
echo "</td></tr>";
} 

echo "</table>";

?>

当我从起始巴士站搜索到终点巴士站时,我没有得到任何结果。

我的数据库看起来像这样:

time(PM) STOP_1 STOP_2 STOP_3 STOP_4 STOP_5 STOP_6 STOP_7 route_no.
13:00     
13:20
13:40
14:00

这个对吗?任何人都可以查看我的代码是否存在问题,或者是否有人对如何改进它有任何建议,我将不胜感激。

亲切的问候,钥匙

4

1 回答 1

0

我认为问题在于and time(time)将其更改为反引号,因为时间是一个关键字,它应该像这样使用 time(`time`)

于 2013-04-16T17:35:58.987 回答