dongmi5020 2018-03-01 13:09
浏览 201
已采纳

获取具有2个或更多条件的foreach循环的值

I am trying to insert multiple record from my HTML form to my Database Using PHP i just learn that it is possible to have foreach loop with 2 or more condition now my problem is how can i get those value and insert it to my database? here is my sample code:

 while($p = mysqli_fetch_assoc($qry)){
   // this loop has more than 1 data to fetch
 ?>
   <input type="hidden" name="studName[]" value="">
   <input type="hidden" name="studId[]" value="">
   <input type="" name="text1[]" value="">
 <?php
 }

Now getting each value from this textbox array, here is my code:

 foreach (array($text1, $studName, $studId) as $data) {
  //qry for inserting value from array in one table
 }
  • 写回答

1条回答 默认 最新

  • doutuan8887 2018-03-01 13:17
    关注

    you can use the variable this way. (if all arrays are the same size).

    foreach($text1 as $key => $text){
       echo $text1[$key];
       echo $studName[$key];
       echo $studId[$key];
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥15 python爬取bilibili校园招聘网站
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置