我一直尝试使用来自MySQL数据库的数据的PHP下拉列表。
我已在下面附上我的代码,我没有收到下拉列表。可以有人帮忙
<?php
$conn = mysql_connect('localhost','root','');
mysql_select_db('qsearch',$conn);
$query = "select Category from information";
$result = mysqli_query($query);
echo '<select id="info" name="info">';
echo '<option value="">-select-</option>';
while ($row = mysqli_fetch_assoc($result)){
?>
<option value="<?php echo $row['Category']; ?>"><?php echo $row['Category']; ?> </option>
<?php
}
echo "</select>";
?>
答案 0 :(得分:2)
因为您的一半功能来自mysql
而其他功能来自mysqli
$conn = mysql_connect('localhost','root','');
mysql_select_db('qsearch',$conn);
$query = "select Category from information";
$result = mysqli_query($query);
while ($row = mysqli_fetch_assoc($result)){
您需要先仔细阅读文档
http://www.php.net/mysqli&amp; http://www.php.net/mysqli_connect