2015-06-28 36 views
0

我試圖從視圖頁面發佈name="std_id[]"的數組。但在嘗試使用print_r($std_id)打印數組時,我找不到任何數據。該代碼如下..使用codeigniter獲取來自帖子數組的數據

鑑於頁:

<?php 
foreach ($all_student as $v_student) { 
?> 
<tr><td style="display:none"><input type="text" value="<?php echo $v_student->std_id ?>" name="std_id[]"></td> 
<td class="center"><?php echo $v_student->std_name; ?></td> 
<?php }?> 

在控制器功能:

$std_id = $this->input->post("std_id[]", true); 
print_r($std_id); 
exit(); 

回答

1

你引用的輸入名字寫錯了。您需要更改線路

$std_id = $this->input->post("std_id[]", true); 

有了:

$std_id = $this->input->post("std_id", true);