我想要製作一個html或php頁面(對於某些自己的學習過程),它可以輸入3個選擇,然後在下一頁顯示結果。從一個html頁面的mysql開始結束日期和下拉菜單
1輸入開始日期 2-輸入結束日期 3-展會服務在下拉菜單中通過MySQL查詢名稱從表中
到目前爲止,我已經設法開始和結束獲得服務名稱表和下拉菜單,它成功地查詢服務表並顯示名稱,但問題是,當我點擊提交我可以看到開始和結束日期的結果,但我無法看到如何在發佈中添加服務選擇。 這是我的代碼。
<!DOCTYPE html>
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script>
$(document).ready(function() {
$("#start_datepicker").datepicker();
$("#end_datepicker").datepicker();
});
</script>
</head>
<body style="font-size:62.5%;">
<form action="test.php" method="post">
Start Date: <input type="text" name="startdate" id="start_datepicker"> <br />
End Date: <input type="text" name="enddate" id="end_datepicker"><br />
<select name="srvname">
<?php
$conn = new mysqli('localhost', 'root', 'SQLPASS', 'radius')
or die ('Cannot connect to db');
$result = $conn->query("select srvname name from rm_services");
while ($row = $result->fetch_assoc()) {
echo "<option value=\"" . $row["id"] . "\">" . $row["name"] . "</option>";
}
?>
</select>
<input type="submit" value="Submit:">
</form>
</body>
</html>
,這是test.php的這將每個表單操作顯示日期
<?php
$STARTDATE = $_POST['startdate'];
$ENDDATE = $_POST['enddate'];
$SRVNAME = $_POST['srvname']; //gets the value -> $row["id"]
echo "<h2>You have entered the following information:</h2>";
echo "<pre>$STARTDATE</pre> ";
echo "<pre>$ENDDATE</pre>";
echo "<pre>$SRVNAME</pre>";
?>
你有一些HTML錯誤。看看'
感謝您的指點,現在我設法更正了代碼,現在三個輸入框顯示一個提交按鈕,但它只提交開始日期到test.php頁面,它不顯示或提交SERVICES名稱到test.php –
你可以更新到你現在有什麼? – chris85