我在html中有一个选择下拉列表,但它不会选择多个值。这是我的代码:
<div class="col-sm-10">
<select multiple id="cmbService" name="cmbService" class="form-control" >
<option value="0">- Select One -</option>
<?php
try{
$dbHost = "localhost";
$dbUser = "mdchadmin";
$dbPass = "123456";
$dbName = "mdch_new";
$conn = new mysqli($dbHost, $dbUser, $dbPass, $dbName);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT PROMO_NUMBER, PROMO_NAME FROM PROMOS where status=1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<option value=\"{$row['PROMO_NUMBER']}\">{$row['PROMO_NAME']}</option>";
}
}
$conn->close();
}catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
?>
</select>
</div>
编辑:现在感谢回答的问题。但是现在我有一个新的问题(有点),我会通过这个
所以我做了你的建议,我把这个$ customer数组放在我的另一个php文件中,结果是:
te,GIAN MARCO.'_'.1235
g,g.'_'.123
where 1235 and 123 are the data on the mobile numbers column.
the problem is , when i do
$mobile=(explode("_",$customers));
it doesn't give me anything when i output it via:
foreach($mobile as $z) {
echo $z; echo "<br>";}
@identity unknown
答案 0 :(得分:5)
您只需在name
属性name="cmbService[]"
<select id="cmbService" name="cmbService[]" class="form-control multiple " >