我已完成此下拉菜单,该菜单从我的数据库中获取不同的POS。它显示为附图所示。
但是我希望将php下拉菜单放在html表中。如第二张图所示。所以我可以更新特定的字段。但我不知道该怎么做,请帮忙! :)
<td><input type="text" name="POS" placeholder="POS" required />
<?php
mysql_connect('localhost', 'root', '');
mysql_select_db('ishop');
$sql = "SELECT DISTINCT POS FROM tbl_st";
$result = mysql_query($sql);
echo "<select name='POS'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['POS'] ."'>" . $row['POS'] ."</option>";
}
echo "</select>";
?>
</td>
</tr>
答案 0 :(得分:0)
试试这个
<td><input type="text" name="POS" placeholder="POS" required />
<?php
mysql_connect('localhost', 'root', '');
mysql_select_db('ishop');
$sql = "SELECT DISTINCT POS FROM tbl_st";
$result = mysql_query($sql);
echo "<select name='POS'>";
while ($row = mysql_fetch_array($result))
{
?>
<option value="<?php echo $row['POS'] ?>"><?php echo $row['POS'] ?></option>;
<?php
}
echo "</select>";
?>
</td>