我使用下面的代码填充php html中的下拉列表,
<?php
$mid="mario";
$sql = "SELECT * FROM tbl_prdy WHERE col_master_id = '$mid'";
$result = mysqli_query($conn,$sql);
echo "<select name='list'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['col_of_fa'] . "'>" . $row['col_of_fa'] . "
</option>";
}
echo "</select>";
?>
但是,我收到内部服务器错误。我调试了代码,发现问题在于上面代码中的以下2行。服务器日志中没有太多信息。你能告诉我以下两行代码会出现什么问题吗?
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['col_of_fa'] . "'>" . $row['col_of_fa'] .
"/option>";
}
答案 0 :(得分:2)
将mysqli与mysql混合
变化
$row = mysql_fetch_array($result)
到
$row = mysqli_fetch_array($result)
答案 1 :(得分:0)
你会用这个
while($row=mysqli_fetch_assoc($result )){
}
或
while($row=mysqli_fetch_array($result )){
}
答案 2 :(得分:0)
//试试这个:
while ($row = mysqli_fetch_array($result)) { ?>
<option value="<?php echo $row['col_of_fa'] ?>" ><?php echo $row['col_of_fa'] ?>
</option>
<?php }