如何显示从我的mysql数据库中选择的下拉列表值。下拉列表取决于我的Category
下拉列表。这些是代码:如何在php中显示从数据库中选择的下拉列表值
<?php $id = $_GET["id"];
if(!$pupcon){
die(mysql_error());
}
mysql_select_db($database_pupcon, $pupcon);
$getDropdown2 = mysql_query("select * from tblitemname where CategoryID = $id");
while($row = mysql_fetch_array($getDropdown2)){
echo "<option value=\"".$row["ItemID"]."\">".$row["Item_Name"]."</option>";
} ?>
以下是第一个下拉列表(Category
),其填充Item Name
下拉代码。
<select name="Category" id="Category" class="field select large" onChange="loadXMLDoc(this.value);">
<?php do { ?>
<option value="<?php echo $row_Recordset1['CategoryID']?>"<?php if (!(strcmp($row_Recordset1['CategoryID'], $row_editRecordset['CategoryID']))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset1['CategoryName']?></option>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); $rows = mysql_num_rows($Recordset1); if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);}?>
</select>
下拉列表不显示任何内容。我编辑了我的问题,并包含了第一个下拉列表的代码。 –
你忘了回声 –
@RohitKumarChoudhary'echo'在哪里?我完全按照它的方式复制了他的代码,并将'$ id'更改为'$ row_Recordset1 ['ItemID']'。我试图创建一个编辑功能,我使用'Recordset1'来显示存储在我的数据库中的值 –