0
這是我的酒店進程 我想顯示數據庫中的某些條件的數據。例如價格。我想顯示的數據高於我們從表單函數提示的價格。我不知道如何解決我的PHP和PHPmyAdmin中的錯誤
<!DOCTYPE html>
<html>
<head>
<title>Hotel</title>
</head>
<body>
<?php
include 'dbh.php';
$price = $_POST['price'];
$query = "SELECT * FROM hotel";
$result = mysqli_query($conn, $query);
?>
<table id="Htable">
<tr class="header">
<th style ="width:60%;">Price</th>
<th style ="width:40%;">Hotel Name</th>
</tr>
<? while($rows = mysqli_fetch_array($result))
{
<? if($price > $rows['h_price'])
{ ?>
$h_price = $rows['h_price'];
$n_hotel = $rows['n_hotel']; \t
?>
<tr>
<td> <?= $h_price ?> </td>
<td> <?= $n_hotel ?> </td>
</tr>
<? } ?>
<? } ?>
</table>
</body>
</html>
這是我的表單頁面,提示價格 這個文件我想要做的形式爲DSS做過濾系統。
<!DOCTYPE html>
<html>
<head>
PHP
</head>
<body>
<form action="hotelprocess.php" method="POST">
<p>
<label>Price:</label>
<input type="text" id="price" name="price" />
</p>
<p>
<input type="submit" name="hotel" />
</p>
</form>
</body>
</html>
這是數據庫連接
<?php
//connect with database
$conn=mysqli_connect("localhost", "root", "", "register");
if(!$conn){
die("connection failed:".mysqli_connect_error());
}
?>
您是否試過僅查詢那些適合您的酒店?像'選擇*從酒店的價格= $價格;'。當然使用>或<而不是=。 – Hienz
這是一團糟。我在代碼中看到許多拼寫錯誤,包括在PHP標記之外使用<?'開始標記和PHP變量。在尋求幫助之前解決您的基本語法錯誤。 – miken32
沒有任何錯誤,我們不能幫助你,因爲@ miken32說你的代碼是一團糟,你有其他PHP開放/關閉標籤內的PHP打開/關閉標籤。 –