如何在搜索页面中执行取件日期和退货日期? [英] How to execute pickup date and return date in search page?

查看:93
本文介绍了如何在搜索页面中执行取件日期和退货日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在车页中,我已经将所有数据输入到mysql数据库中。所以我想让用户轻松找到提取日期和返回日期的车。所以,我在搜索中搜索了提取日期和返回日期page.But错误是无法执行。



我尝试过:



car.php

< / body>

< table align ='center'width ='40%'border ='0' cellpadding ='0'cellspacing ='0'>

< tr>

< form action =search.phpmethod =postenctype = multipart / form-data>

< td>< input type =datename =pickup_dateplaceholder =pickup_datestyle ='height:38px'required />< ; / td>

< td>< input type =datename =return_dateplaceholder =return_datestyle ='height:38px'required />< / td>

< td>< input type =submitname =submitbookvalue =搜索style ='background-color:blue ; border:none;白颜色;填充:10px 10px; text-align:center; text-decoration:none; display:inline-block; font-size:14px;'/>< / td>

< / div>

< / form>

< ; / table>



<?php



$ link = mysqli_connect(localhost, root,,online_car_rental);



if($ link === false){

die(错误:无法连接。。mysqli_connect_error());

}

$ pickup_date = $ _GET ['pickup_date'];

$ return_date = $ _GET ['return_date'];

$ query =SELECT pickup_date,return_date FROM car where pickup_date ='$ pickup_date'and return_date ='$ return_date';

if($ result = mysqli_query($ link,$ sql)){

if(mysqli_num_rows($ result)> 0){

echo< table> ;

echo< tr>;

echo< th> Id< / th>;

echo< th>名称< / th>;

echo< th>价格(RM)< / th& gt;;

echo< th>颜色< / th>;

echo< th>模式< / th>;

echo< th> Image< / th>;

echo< th> Status< / th>;

echo< th>添加到预订< / th>;



echo< / tr>;

while($ row = mysqli_fetch_array ($ result)){

echo< tr>;

echo< td> 。 $ row ['car_id']。 < / td>;

echo< td> 。 $ row ['car_name']。 < / td>;

echo< td> 。 $ row ['car_price']。 < / td>;

echo< td> 。 $ row ['car_colour']。 < / td>;

echo< td> 。 $ row ['car_mode']。 < / td>;

echo< td>< img src ='。 $ row ['car_image']。 'height ='100'width ='100'>< / td>;

echo< td> 。 $ row ['car_status']。 < / td>;

echo< td> 。 $ row ['pickup_date']。 < / td>;

echo< td> 。 $ row ['return_date']。 < / td>;

echo< td>< button onclick = \booking_car('。$ row ['car_id']。

')\>预订< /按钮>



< / td>;



echo< / tr>;

}

echo< / table>;

//免费结果设置

mysqli_free_result($ result);

} else {

echo找不到与您的查询匹配的记录。;

}

} else {

echo错误:无法执行$ sql。。 mysqli_error($ link);

}



mysqli_close($ link);

?>



< / html>

In the car page,i already input all the data into mysql database.So i want to ease the user to find the car that available on pickup date and return date.So,I made search pickup date and return date in search page.But the error is "could not be execute".

What I have tried:

car.php
</body>
<table align='center' width='40%' border='0' cellpadding='0' cellspacing='0'>
<tr>
<form action="search.php" method="post" enctype="multipart/form-data">
<td><input type="date" name="pickup_date" placeholder="pickup_date" style='height:38px' required /></td>
<td><input type="date" name="return_date" placeholder="return_date" style='height:38px' required /></td>
<td><input type="submit" name="submitbook" value="Search" style='background-color: blue; border: none; color: white; padding: 10px 10px; text-align: center; text-decoration: none; display: inline-block; font-size: 14px;'/></td>
</div>
</form>
</table>

<?php

$link = mysqli_connect("localhost", "root", "", "online_car_rental");

if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$pickup_date = $_GET['pickup_date'];
$return_date = $_GET['return_date'];
$query="SELECT pickup_date,return_date FROM car where pickup_date ='$pickup_date' and return_date = '$return_date'";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
echo "<table>";
echo "<tr>";
echo "<th>Id</th>";
echo "<th>Name</th>";
echo "<th>Price(RM)</th>";
echo "<th>Colour</th>";
echo "<th>Mode</th>";
echo "<th>Image</th>";
echo "<th>Status</th>";
echo "<th>Add to Booking</th>";

echo "</tr>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['car_id'] . "</td>";
echo "<td>" . $row['car_name'] . "</td>";
echo "<td>" . $row['car_price'] . "</td>";
echo "<td>" . $row['car_colour'] . "</td>";
echo "<td>" . $row['car_mode'] . "</td>";
echo "<td><img src='" . $row['car_image'] . "' height='100' width='100'></td>";
echo "<td>" . $row['car_status'] . "</td>";
echo "<td>" . $row['pickup_date'] . "</td>";
echo "<td>" . $row['return_date'] . "</td>";
echo "<td><button onclick=\"booking_car('" . $row['car_id'] .
"')\">Book</button>

</td>";

echo "</tr>";
}
echo "</table>";
// Free result set
mysqli_free_result($result);
} else{
echo "No records matching your query were found.";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}

mysqli_close($link);
?>

</html>

推荐答案

link = mysqli_connect(localhost,root, ,online_car_rental);



if(
link = mysqli_connect("localhost", "root", "", "online_car_rental");

if(


link === false){

死(错误:无法连接。。mysqli_connect_error());

}
link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}


pickup_date =
pickup_date =


这篇关于如何在搜索页面中执行取件日期和退货日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆