獲得唯一入選的行字段值如果你想獲得一個LIS
<?php
$data[] = array('ProductID'=>123,"Quantity"=>1,"Price"=>"2.00");
$data[] = array('ProductID'=>234,"Quantity"=>2,"Price"=>"1.50");
$data[] = array('ProductID'=>345,"Quantity"=>1,"Price"=>"4.59");
$data[] = array('ProductID'=>456,"Quantity"=>4,"Price"=>"1.99");
foreach($data as $row){ ?>
<tr>
<td><input type="checkbox" name="product[<?php echo $row['ProductID'];?>][select]" /></td>
<td><input type="text" value="<?php echo $row['Quantity']; ?>" name="product[<?php echo $row['ProductID'];?>][qty]" /></td>
<td><input type="text" value="<?php echo $row['Price']; ?>" name="product[<?php echo $row['ProductID'];?>][price]" /></td>
</tr>
<?php }
爲您提供::
// Just loop through the [product] array looking for the 'select' = 'on'
Array
(
[product] => Array
(
[123] => Array
(
[qty] => 1
[price] => 2.00
)
[234] => Array
(
[select] => on
[qty] => 2
[price] => 1.50
)
[345] => Array
(
[qty] => 1
[price] => 4.59
)
[456] => Array
(
[qty] => 4
[price] => 1.99
)
)
)
所有項目用一記是否選擇或不,只是改變你的表單名稱位(如果我明白你在找什麼...)的婷
要獲得所選項目:
if(!empty($_POST['product'])) {
foreach($_POST['product'] as $row) {
if(!empty($row['select'])) {
print_r($row);
}
}
}
感謝您的答覆,但你可以請寫代碼是如何遍歷在S選 –
相同的方式,做表:'的foreach($ _ POST [「產品」]爲$行){... etc.' – Rasclatt
再次感謝你,但請原諒我真的do'not知道如何收集僅選擇行字段值將ü請寫完整的代碼只爲選定的行它可以是一個或多個? –