我有一个从db查询填充的下面的下拉列表。 我正在努力想办法添加从这个下拉框中选择的项目 基本上是一个像购物车这样的列表,允许我从这个下拉框中添加多个。 你有没有人可以用这个指导我
<?php
mysql_connect('localhost', 'blah', 'password');
mysql_select_db('reporting');
$sql = "SELECT DISTINCT ProductNumber, Description FROM Stock WHERE ProductGroup ='800'";
$result = mysql_query($sql);
echo "<select name='PRODS'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['Description'] . "'>" . $row['Description'] . "</option>";
}
echo "</select>";
?>
答案 0 :(得分:0)
尝试:
echo "<select name='PRODS' multiple>";
使用此功能,您可以从选择框中选择多个值。
答案 1 :(得分:0)
试试这个......
<?php
mysql_connect('localhost', 'blah', 'password');
mysql_select_db('reporting');
$sql = "SELECT DISTINCT ProductNumber, Description FROM Stock WHERE ProductGroup ='800'";
$result = mysql_query($sql);
echo "<select name='PRODS' multiple>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['Description'] . "'>" . $row['Description'] . "</option>";
}
echo "</select>";
?>