需要帮助处理动态表单字段

时间:2018-03-16 11:37:34

标签: php mysql forms dynamic

enter image description here

我有数据库中的学生。每个学生都分为多个班级。我正在动态加载学生和学生班级表中的字段以更新数据(如附图所示)。我使用以下循环来接收和显示数据:

for($i=0;$i<$_POST["studnor"];$i++)
{
    //$result = ($_POST["result"][$i]!="")?$_POST["result"][$i]:'';
    $sid = $_POST["sid"][$i];
    echo '<br>Student ID:'.$sid.'<br>';
    echo 'No. of Classes:'.$_POST["clnor"][$i].'<br><br>';
    $clnor = $_POST["clnor"][$i];
    for($j=0;$j<$clnor;$j++)
    {
        $classid = ($_POST["classid"][$j]!="")?$_POST["classid"][$j]:'';
        $result = ($_POST["result"][$j]!="")?$_POST["result"][$j]:'';
        echo $classid.'<br>';
        echo $result.'<br>';
    }
}

$ _ POST返回:

array (size=8)
'result' => 
array (size=19)
  0 => string '56%' (length=3)
  1 => string '65%' (length=3)
  2 => string '85%' (length=3)
  3 => string '56%' (length=3)
  4 => string '64%' (length=3)
  5 => string '63%' (length=3)
  6 => string '56%' (length=3)
  7 => string '24%' (length=3)
  8 => string '62%' (length=3)
  9 => string '70%' (length=3)
  10 => string '45%' (length=3)
  11 => string '55%' (length=3)
  12 => string '65%' (length=3)
  13 => string '36%' (length=3)
  14 => string '62%' (length=3)
  15 => string '56%' (length=3)
  16 => string '45%' (length=3)
  17 => string '70%' (length=3)
  18 => string '74%' (length=3)
  'isretained' => 
  array (size=14)
  0 => string 'on' (length=2)
  1 => string 'on' (length=2)
  2 => string 'on' (length=2)
  3 => string 'on' (length=2)
  4 => string 'on' (length=2)
  5 => string 'on' (length=2)
  6 => string 'on' (length=2)
  7 => string 'on' (length=2)
  8 => string 'on' (length=2)
  9 => string 'on' (length=2)
  10 => string 'on' (length=2)
  11 => string 'on' (length=2)
  12 => string 'on' (length=2)
  13 => string 'on' (length=2)
  'comments' => 
  array (size=19)
  0 => string '' (length=0)
  1 => string '' (length=0)
  2 => string 'not retained' (length=12)
  3 => string '' (length=0)
  4 => string '' (length=0)
  5 => string 'Not retained' (length=12)
  6 => string '' (length=0)
  7 => string '' (length=0)
  8 => string '' (length=0)
  9 => string '' (length=0)
  10 => string 'dadas ads asd' (length=13)
  11 => string '' (length=0)
  12 => string '' (length=0)
  13 => string '' (length=0)
  14 => string '' (length=0)
  15 => string '' (length=0)
  16 => string 'aada sssff  ' (length=12)
  17 => string '' (length=0)
  18 => string '' (length=0)
  'classid' => 
  array (size=19)
  0 => string '421' (length=3)
  1 => string '422' (length=3)
  2 => string '423' (length=3)
  3 => string '343' (length=3)
  4 => string '342' (length=3)
  5 => string '423' (length=3)
  6 => string '422' (length=3)
  7 => string '421' (length=3)
  8 => string '343' (length=3)
  9 => string '342' (length=3)
  10 => string '423' (length=3)
  11 => string '422' (length=3)
  12 => string '421' (length=3)
  13 => string '343' (length=3)
  14 => string '342' (length=3)
  15 => string '421' (length=3)
  16 => string '423' (length=3)
  17 => string '343' (length=3)
  18 => string '342' (length=3)
  'clnor' => 
  array (size=4)
  0 => string '5' (length=1)
  1 => string '5' (length=1)
  2 => string '5' (length=1)
  3 => string '4' (length=1)
  'sid' => 
  array (size=4)
  0 => string '1961' (length=4)
  1 => string '1997' (length=4)
  2 => string '1951' (length=4)
  3 => string '2018' (length=4)
  'sessid' => string '71' (length=2)
  'studnor' => string '4' (length=1)

“studnor”不是。学生隐藏的领域。这为所有学生显示相同的数据。请帮助我检索此表单中的数据。感谢

0 个答案:

没有答案