Php 如何保存在动态表的每一行中输入的文本框值

Php 如何保存在动态表的每一行中输入的文本框值,php,Php,我有一个动态表格,每行有4个文本框:数量、价格、折扣和小计。如何获得一个数组,该数组中的每一行的每一个文本框中都输入了每个值?例如: [0]=> { ["Price"]=>10 ["Qty"]=>5 ["Discount"]=>1 ["Subtotal"]=>49 } [1]=> { ["Price"]=>5 ["Qty"]=>10 ["Discount"]=>2 ["Subt

我有一个动态表格,每行有4个文本框:数量、价格、折扣和小计。如何获得一个数组,该数组中的每一行的每一个文本框中都输入了每个值?例如:

[0]=> {
    ["Price"]=>10
    ["Qty"]=>5
    ["Discount"]=>1
    ["Subtotal"]=>49
}

[1]=> {
    ["Price"]=>5
    ["Qty"]=>10
    ["Discount"]=>2
    ["Subtotal"]=>48
}
这是我的代码:

<?php
while($iArticles < count($listeArticlePourUnDossier))
{
?>  
    <tr>
        <td><?php echo ($listeArticle[$iArticles]['name']); ?></td>
        <td><input type="text" name="Price[]" id="Price"/></td>
        <td><input type="text" name="Qty[]" id="Qty" /></td>
        <td><input type="text" name="Discount[]" id="Discount" /></td>
        <td><input type="text" name="Subtotal[]" id="Subtotal" /></td>
    </tr>
<?php       
$iArticles++;
}
?>  


谢谢

让每个HTML名称都成为一个带有索引的数组

<?php
$x=0;
while($iArticles < count($listeArticlePourUnDossier))
{
  $x++;
?>  
    <tr>
        <td><?php echo ($listeArticle[$iArticles]['name']); ?></td>
        <td>
            <input type="text" name="Price[<?php echo $x; ?>]" id="Price_<?php echo $x; ?>"/>
            <input type="text" name="Qty[<?php echo $x; ?>]" id="Qty_<?php echo $x; ?>" />
            <input type="text" name="Discount[<?php echo $x; ?>]" id="Discount_<?php echo $x; ?>" />
            <input type="text" name="Subtotal[<?php echo $x; ?>]" id="Subtotal_<?php echo $x; ?>" />
        </td>
    </tr>
<?php       
$iArticles++;
}
?>  


我不是100%确定我掌握了问题的真实性质,以下内容还没有经过测试,但我希望会有用——尽管这里没有对提供的POST数据进行健全性/有效性检查

$prices=$_POST['Price'];
$qtys=$_POST['Qty'];
$discounts=$_POST['Discount'];
$subs=$_POST['Subtotal'];

$data=[];

foreach( $prices as $index => $price ){
    $data[]=[
        'price'     =>  $price,
        'qty'       =>  $qtys[ $index ],
        'discount'  =>  $discounts[ $index ],
        'subtotal'  =>  $subs[ $index ]
    ];
}

printf( '<pre>%s</pre>', print_r( $data, true ) );
$prices=$\u POST['Price'];
$qtys=$_POST['Qty'];
$折扣=$_POST[‘折扣’];
$subs=$_POST[‘小计’];
$data=[];
foreach(价格为$index=>$price){
$data[]=[
“价格”=>美元价格,
“数量”=>$qtys[$index],
“折扣”=>$折扣[$指数],
“小计”=>$subs[$index]
];
}
printf(“%s”,print_r($data,true));

@RamRider,哦,我错了,我得到了我想要的数组……谢谢……非常感谢