dongre6404 2016-08-23 03:58
浏览 16
已采纳

从动态多维形式获取

I'm trying to GET all data from dynamic multidimensional form. Each column has different name and id like this :

$result2 = mysql_query("SELECT * FROM tempselect");
while($row = mysqli_fetch_row($result2))
{
   for ($i = 0; $i < count($result2) ; $i++) { 
   echo "<tr>";
        for ($j = 0; $j < 12 ; $j++) { 
            echo "<td><input type=\"text\" size=\"4\" name=\"" . $i++ ."[]\"id=\"" .$row[$j] ."\" value=" . $row[$j] . "></td>";
         }
    }
}

Code above works properly, each column got different name and id. the output is like this : enter image description here

The purpose from this form is to edit data from database and use it for next process. Now i want to combine all data into 1 multidimensional array like this :

2  4  4  .  .  . 0
3  .  .  .  .  . 0
3  .  .  .  .  . 0
.  .  .  .  .  . 0
.  .  .  .  .  . 0
3  .  .  .  .  . 0

I tried using code below, but only the first column saved into $data :

for ($i=0; $i <  count($_GET['0']); $i++) { 
    for ($j=0; $j < count($_GET['submit_edit']); $j++) { 
        $data =$_GET[$j];
    }
 }
  • 写回答

1条回答 默认 最新

  • duanjurong1347 2016-08-23 04:11
    关注
       $data = array();
        for ($i=0; $i <  count($_GET['0']); $i++) { 
            for ($j=0; $j < count($_GET['submit_edit']); $j++) { 
                $data[] =$_GET[$j];
            }
           }
    

    This is just as you are doing i see $data has to be $data[] . However I dont know what rest you are doing. If this solves the problem then good, if doesnt then please make the question more clear related to $_GET['submit_edit'] and other $_GET's

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

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法