duanlv1366 2019-07-21 02:40
浏览 88
已采纳

Multidimentionnal $ _POST提取问题(仅返回1个值)

I have an issue with this :

PART OF MY FORM

  <div class="row">
                                        <div class="col-sm-6">
                             <div class="form-group">
                              <input class="form-control" name="config_name[]" type="text" placeholder="Nom"/>
                             </div></div>
                                 <div class="col-sm-6">
                             <div class="form-group">
                              <input class="form-control" name="config_pname[]" type="text"  placeholder="Prénom"/>
                             </div></div></div>
                                 <div class="row">
                                        <div class="col-sm-12">
                             <div class="form-group">
                              <input class="form-control" name="config_phone[]" type="text" placeholder="Numéro de mobile"/>
                             </div></div></div>
                                 <div class="row">
                                        <div class="col-sm-12">
                             <div class="form-group">
                              <input class="form-control" name="config_mail[]" type="text" placeholder="Adresse Mail"/>
                             </div></div></div>
<?php 
    $glprt_type = "dx";
    echo '<input type="checkbox" name="config_'.strtolower($glprt_type).'[][]" value="'.$glprt_type.' '.$glprt_subtype.' '.$glprt_name.'"><b style="font-size: 12px;"> '.$glprt_type.' '.$glprt_subtype.' - '.$glprt_name.'</b> <br>'; ?>

PHP PROCESS

for ($i = 0; $i < count($_POST['config_pname']); $i++) {
echo $_POST['config_type'][$i].'<br />';
                echo  date('Y-m-d').'<br />';
                echo  $_POST['config_pname'][$i].'<br />';
                echo  $_POST['config_name'][$i].'<br />';
                for ($j = 0; $j < count($_POST['config_dx'][$i]); $j++) {
    echo $_POST['config_dx'][$j][$i].'<br />';
                    }
            }

The point is that I only get the first $_POST['config_dx'] record even if I have 3 sent througt POST Method.

What am I doing wrong ? 1/ echo count($_POST['config_dx'][$i] returns "1"

2/ if I replace in the loop

echo $_POST['config_dx'][$j][$i].'<br />';

by

echo $_POST['config_dx'][0][$i].'<br />'; echo $_POST['config_dx'][1][$i].'<br />'; echo $_POST['config_dx'][2][$i].'<br />';

my 3 results apperas so the loop seems not to loop :)

Thanks a lot

  • 写回答

1条回答 默认 最新

  • drake900918 2019-07-21 12:11
    关注

    Did you remove the [$i] in your second for loop.

    Like this:

    for ($j = 0; $j < count($_POST['config_dx']); $j++) 
    

    Hope it helps!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器