當我在列表框中選擇多個設備並按下提交時,我看到一個PHP表單,我在後端php腳本中只看到一個值。php從列表框中選擇多個值
PHP形式:
<br><br>
Select Devices:<br>
<?php
<form target="iframe_b" action="/php_src/sendNIDDConfigReq.php" method="POST"
echo "sending data">
<fieldset>
<legend style="font-size:150%"><b>send NIDDRequest</b></legend>
<br> <br>
Select SCEF:<br>
<?php
$dbhost = 'localhost:3036';
$dbuser = 'root';
$dbpass = 'XXXX';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$conn) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("ApplicationServer") or die(mysql_error());
// Get all the data from the "example" table
$result = mysql_query("SELECT EXTERNAL_ID FROM DEVICE_DETAILS") or die(mysql_error());
echo "<select name='External_ID' id='id_extID' multiple='multiple'>";
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['EXTERNAL_ID'] . "'>" . $row['EXTERNAL_ID'] . "</option>";
}
echo "</select>";
send
?>
<br><br>
<input type="button" id="select_all" name="select_all" value="Select All">
<input type="button" id="de_select_all" name="de_select_all" value="DeSelect All">
<br><br>
<input type="submit" value="Submit">
</fieldset>
</form>
<script type="text/javascript">
$('#select_all').click(function() {
$('#id_extID option').prop('selected', true);
});
$('#de_select_all').click(function() {
$('#id_extID option').prop('selected', false);
});
</script>
服務器代碼:sendNIDDConfigReq.php
輸出: 陣列([SCEF_Name] => SCEF1 [EXTERNAL_ID] => [email protected] )SCEF_Name = SCEF1 [email protected]
'名稱= 「EXTERNAL_ID []」 multiple' – Blinkydamo
變更名稱= 'EXTERNAL_ID' 來命名= 'EXTERNAL_ID []' 這樣的形式發送所選項目的數組爲php – jeff