gpt4 book ai didi

php - 数组未转发数据

转载 作者:行者123 更新时间:2023-12-04 05:53:32 26 4
gpt4 key购买 nike

我有一个需要 10 行相似数据的表单。该表单收集产品代码、描述和数量。我遍历 10 行并使用数组来收集信息。

$code = array();
$description = array();
$quantity = array();

<?php
for($i=0; $i<10; $i++){
?>
<div class="quote-row">
<div class="quote-id">
<?php echo $i+1; ?>
</div>
<div class="quote-code">
<input type="text" class="quotecode" name="<?php echo $code[$i]; ?>" />
</div>
<div class="quote-description">
<input type="text" class="quotedescription" name="<?php echo $description[$i]; ?>" />
</div>
<div class="quote-quantity">
<input type="text" class="quotequantity" name="<?php echo $quantity[$i]; ?>" />
</div>
</div>
<?php
}
?>

在接下来的页面上,我使用 $_POST['code'], $_POST['description'], $_POST['quantity']携带数据并尝试使用它。

我的问题是数据似乎没有到达?

使用 for 循环,我还能提交表单并转发所有数据吗?

希望这能提供尽可能多的信息,谢谢!

最佳答案

您在 name 属性中给出数组的值。你的数组是空的,所以你的名字也是空的。

尝试这个:

<?php
for($i=0; $i<10; $i++){
?>
<div class="quote-row">
<div class="quote-id">
<?php echo $i+1; ?>
</div>
<div class="quote-code">
<input type="text" class="quotecode" name="code[]" />
</div>
<div class="quote-description">
<input type="text" class="quotedescription" name="description[]" />
</div>
<div class="quote-quantity">
<input type="text" class="quotequantity" name="quantity[]" />
</div>
</div>
<?php
}
?>

姓名[ ] format 自动使您的数据成为数组。

关于php - 数组未转发数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9787178/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com