我在这里给出了我的代码。
$std_details = $this->db->query('CALL table("'.$field1.'"')->result_array();
$form_list = array();
foreach($std_details as $details)
{
$id =$details['id'];
$list = $this->db->query('CALL table("'.$field1.'","'.$field2.'","'.$field3.'","'.$field4.'","'.$field5.'", "'.$field6.'")')->result_array();
array_push($form_list, $list);
foreach($list as $datalist1)
{
foreach ($datalist1 as $datalist)
{
$subdata = array();
$subdata[] = $datalist['field_name1'];
$subdata[] = $datalist['field_name2'];
$action = '<div class="hidden-sm hidden-xs action-buttons">
<a class="blue" href="'.base_url().'folder/controller/functionname/'.$details['id'].'" title="Preview" ><i class="fa fa-eye bigger-130" aria-hidden="true"></i></a>
</div>';
$subdata[] = $action;
$data['data'][$Count] = $subdata;
$Count++;
}
}
}
echo json_encode($data);
exit;
在这里,我必须从$ std_details获取$ details [&#39; id&#39;],我必须在$ action变量中的下面显示的foreach循环中传递这些id。现在我只得到每一行数组的最后一个值,即$ details [&#39; id&#39;]。由于我不熟悉编码,请帮助我解决问题并指出错误。