-1
我有一個從數據庫中取出日期(date_entered)加載的下拉列表。我的表格包含大小,項目,說明,單位,價格,用法和項目編號。如何從下拉選項填充表格?
我的數據庫有相同的,但也是一個date_entered。當用戶從下拉菜單中選擇日期時,我需要填寫相應的數據(大小,項目等)。然而,我不知道如何去做,因爲我認爲PHP只在請求頁面時加載數據。以下是我的下拉列表的代碼。我會添加一個顯示按鈕供用戶點擊嗎?任何幫助,將不勝感激。謝謝
<label for="">Select invoice</label>
<div class="input-group">
<select name="invoice" id="invoice" class="form-control" type="text" list="id" placeholder="Select Number"value="<?php $Date_entered ?>">
<span class="input-group-btn">
<datalist name="id" id="id"> <span class="caret"></span>
<?php
include("Connect.php");
$result=mysql_query("SELECT Date_entered FROM orders");
while ($row = mysql_fetch_array($result)) {
unset($id);
$id = $row['Date_entered'];
echo '<option value="'.$id.'">'.$id.'</option>';
}
?>
</datalist>
</span>
</select>
</div>
一旦用戶選擇一個日期,你可以使用ajax來加載更多的數據。看看這個 - http://stackoverflow.com/questions/32389767/how-do-i-execute-a-php-query-on-select-option-choice-using-ajax – vabii