0
作爲標題說我目前正在嘗試將<select>
中的值從視圖傳遞到控制器以批量插入 以下是零件段從視圖類:將選擇輸入陣列從視圖傳遞到控制器(代碼點火器)
foreach($results as $row){echo '<tr>';
echo '<td> <select name="Select[]" value="'.$count.'" >
<option value="Select">Select</option>}
<option value="P">P</option>
<option value="F">F</option>
</select></td>';
echo '<td> <select name="Select2[]" value="'.$count2.'" >
<option value="Select">Select</option>}
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
<option value="F">F</option>
</select></td>';
$count++;
$count2++;
}
下面是代碼從控制器類的段:
$something = $this->input->post('select');
$something2 = $this->input->post('select2');
$classID = $this->input->post('classID');
$studentID = $this->input->post('studentID');
$count = 0;
$insertCount = 0;
$newEntries = array();
$newRow = array (
"employeeID" == $myID[0]->employeeID,
"studentID" == $studentID[$count]->studentID,
"type" == 'Midterm',
"grade" == $something[$index[$count]],
"classID" == $classID[$index[$count]]
);
die(print_r($newRow));
$newRow2 = array (
"employeeID" == $myID[0]->employeeID,
"studentID" == $classID[$index[$count]],
"type" == 'Final',
"grade" == $something2[$index[$count]],
"classID" == $classID[$index[$count]]
);
$newEntries[$index[$insertCount]] == $newRow;
$insertCount++;
$newEntries[$index[$insertCount]] == $newRow2;
$insertCount++;
$count++;
}
所以問題是,對於階級和學生證的是隻傳遞的最後結果結果返回給控制器。我可以用這個錯誤住了,但現在什麼真正重要的是,當這個運行$一些只包含由die(print_r($something));
我想你應該在開始時初始化$ count = 0。 – CodeCanyon