Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在Codeigniter中从服务器端获取id或将id传递给数据表?_Php_Codeigniter_Datatable - Fatal编程技术网

Php 如何在Codeigniter中从服务器端获取id或将id传递给数据表?

Php 如何在Codeigniter中从服务器端获取id或将id传递给数据表?,php,codeigniter,datatable,Php,Codeigniter,Datatable,我在codeigniter中处理datatables服务器端处理。一切正常,但我想在某些列中从控制器传递id 我已尝试此代码,但未收到id: MyController foreach($fetch\u数据为$row){ $sub_array=array(); $sub_数组[]=$no++; $sub_数组[]=“$row->program”; $sub_数组[]=$row->sement; $sub_array[]=$row->name; } 在此之后,表格列如下所示。Program 如何

我在
codeigniter中处理
datatables
服务器端处理。一切正常,但我想在某些列中从控制器传递
id

我已尝试此代码,但未收到
id

MyController

foreach($fetch\u数据为$row){
$sub_array=array();
$sub_数组[]=$no++;
$sub_数组[]=“$row->program”;
$sub_数组[]=$row->sement;
$sub_array[]=$row->name;
}
在此之后,表格列如下所示。
Program

如何在
程序
表单中接收
id

使用更新

$sub_array[] = "<td id=".$row->id.">".$row->program."</td>";
$sub_array[]=”.$row->program.”;
$sub_array[]=“$row->program”

在上面的代码中,您已将
$row->id
包装在单引号(')中,这导致了一个问题。 使用更新您的代码


$sub_array[]=”.$row->program.”

您可以使用onclick函数执行此任务。当您单击特定的td时,值将进入函数并执行ajax

$sub_array[] = "<td onclick='your_function(".$row->id.")'>".$row->program."</td>";

我使用服务器处理中的
datatables
我需要id或一些其他属性,因为我想在单击特定列时将其转换为文本字段,然后我将在Ajax的帮助下更新该数据。您有更好的方法吗?为什么要从何处传递id?您需要什么?您不应该从控制器中生成任何html标记——这就是视图层的用途。我们没有足够的信息来提供专业的答案。
function your_function(id='')
{
  if(id!='')
  {
    //your ajax call here
  }
}