使用数组的选项列表 - php
option list using array - php
数据库中的数据已经没问题了。我的问题是,它在选项列表中没有出现,只是空白,尽管当我将光标放在选项列表上时,它显示有数据
<select style="width: 100px" id="txteventroomtype" onchange="selectfunctionroom(this.value);">
<?php
$getroomtype = "select category from tblroomcat";
$otherroomtyperesult = mysql_query($getroomtype);
while($otherroomtype = mysql_fetch_array($otherroomtyperesult))
{ echo "<option value='" . $otherroomtype[0] . "'></option>"; }
?>
</select>
因为您没有在 <option>???</option>
之间使用数据
示例:
{ echo "<option value='" . $otherroomtype[0] . "'>".$yourDBvalue."</option>"; }
旁注:
停止使用已弃用的 mysql_*
扩展并在 PHP 中关闭 7,使用 mysqli_*
或 PDO
。
请尝试以下代码
<select style="width: 100px" id="txteventroomtype" onchange="selectfunctionroom(this.value);">
<?php
$getroomtype = "select category from tblroomcat";
$otherroomtyperesult = mysql_query($getroomtype);
while($otherroomtype = mysql_fetch_array($otherroomtyperesult))
{ echo "<option value='" . $otherroomtype[0] . "'>".$otherroomtype[0]."</option>"; }
?>
</select>
数据库中的数据已经没问题了。我的问题是,它在选项列表中没有出现,只是空白,尽管当我将光标放在选项列表上时,它显示有数据
<select style="width: 100px" id="txteventroomtype" onchange="selectfunctionroom(this.value);">
<?php
$getroomtype = "select category from tblroomcat";
$otherroomtyperesult = mysql_query($getroomtype);
while($otherroomtype = mysql_fetch_array($otherroomtyperesult))
{ echo "<option value='" . $otherroomtype[0] . "'></option>"; }
?>
</select>
因为您没有在 <option>???</option>
示例:
{ echo "<option value='" . $otherroomtype[0] . "'>".$yourDBvalue."</option>"; }
旁注:
停止使用已弃用的 mysql_*
扩展并在 PHP 中关闭 7,使用 mysqli_*
或 PDO
。
请尝试以下代码
<select style="width: 100px" id="txteventroomtype" onchange="selectfunctionroom(this.value);">
<?php
$getroomtype = "select category from tblroomcat";
$otherroomtyperesult = mysql_query($getroomtype);
while($otherroomtype = mysql_fetch_array($otherroomtyperesult))
{ echo "<option value='" . $otherroomtype[0] . "'>".$otherroomtype[0]."</option>"; }
?>
</select>