我正在制作酒店预订系统,因此在选择城市选项中,它将从数据库中获取数据,显示数据库中唯一的城市。我只是在下面的代码中硬编码,它将始终显示所有城市。如何动态选择? 风格,
<div data-role="fieldcontain" style="width: 80px" >
<p style="float: left;"><label for="select-choice-1" class="select" >Select City</label>
<select
name="select-choice-1" id="select-choice-1">
<option value="chennai">Chennai</option>
<option value="bangalore">Bangalore</option>
<option value="delhi">Delhi</option>
<option value="kolkata">Kolkata</option>
<option value="hyderabad">Hyderabad</option>
<option value="secunderabad">Secunderabad</option>
<option value="mumbai">Mumbai</option>
</select>
</p>
</div>
答案 0 :(得分:1)
试试这个
<select name="select-choice-1" id="select-choice-1">
<?php $mysql = mysql_query("select city from citytable");
while($fetchcity = mysql_fetch_array($mysql)){ ?>
<option value="mumbai"><?php echo $fetchcity['cityfieldname']; ?></option>
<?php } ?>
</select>