我正在开发一个比较汽车价格的网站:
用户应输入:year make model
数据库结构示例(&E):
id—年份—品牌—型号
1 2018菲亚特庞托
2个座位里昂
3 2017现代veloster
所以现在我要显示selectbox,但我需要它在提交表单之前获取selectbox的值。
<div>
<?php
$cars = "SELECT distinct year FROM `cars` ";
$carsResult = mysqli_query($conn, $cars);
?>
<select name="year" class="selectStyle">
<option disabled selected >Year</option>
<?php
if(mysqli_num_rows($carsResult) > 0){
while($row = mysqli_fetch_assoc($carsResult)){
?>
<option id="year" value="<?php echo $row['year']; ?>"><?php echo $row['year']; ?></option>
<?php
}
} else {
?>
<option value="">0 results</option>
<?php
}
?>
</select>
<
<select name="make" class="selectStyle">
<option disabled selected>Make</option>
// Here I need to display more
</select>
</div>
所以在第二个select中,我只需要显示所选年份:“select make from cars where year={users year}”如何将用户选择的年份放到sql查询中?
所以在我检查完之后:“从年份={users year}和车型={users model}的车中选择车型”
请帮帮我,我现在永远在努力!
暂无答案!
目前还没有任何答案,快来回答吧!