0

我在显示我通过从我制作的 MySQL 数据库获取数据的表单中检查的每篇文章的数量时遇到问题。

这是我的代码:

        <?php foreach ($results_articles as $input) : ?>
        <input type="text" name="<?php echo $input->id_article; ?>_txtbox[]" style="text-align: center; width:30px;"></input>
        <input
            type="checkbox" 
            name="checked_articles[]"
            value="<?php echo $input->id_article; ?>">
        <?php echo "(".
                        ($input->ref_article).")".
                        ($input->nom_article)." (".
                        ($input->prix_article)." €)"; ?><br>
    <?php endforeach; ?>

因此,“checked_articles”在我的下一页上正确显示;但我真的不知道如何显示每件检查的数量。

我需要你的帮助!

谢谢!如果您有任何其他信息,我当然会回复!

4

1 回答 1

0

我认为“数量”放在文本input中,如果是这样,它应该可以使用:

foreach ($_POST['checked_articles'] as $checked_id)
{
    $quantity = $_POST[$checked_id . '_txtbox'];
}

但是,由于txtbox输入被命名为数组,$quantity会导致数组。也许那不是你想要的。然后你可以这样做:

<input type="text" name="txtbox[<?php echo $input->id_article; ?>]" style="text-align: center; width:30px;" />

有了这个,文本框将可以使用:

$_POST['txtbox'][$checked_id];
于 2013-03-01T13:15:22.213 回答