Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.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 代码点火器:此->;数据表->;选择(样本)->;来自(样本)——>;where()_Php_Jquery_Mysql_Codeigniter - Fatal编程技术网

Php 代码点火器:此->;数据表->;选择(样本)->;来自(样本)——>;where()

Php 代码点火器:此->;数据表->;选择(样本)->;来自(样本)——>;where(),php,jquery,mysql,codeigniter,Php,Jquery,Mysql,Codeigniter,请帮帮我。我不能正确使用我的数据表。我想做的是 从表中选择并使用where功能。但是我做不好 这是我的控制器代码 public function reporttable () { $zz = array('empnumber' => $this->input->post('empnumber')); //$this->db->order_by("surname", "asc"); $this->da

请帮帮我。我不能正确使用我的数据表。我想做的是

从表中选择并使用
where
功能
。但是我做不好

这是我的控制器代码

 public function reporttable ()
    {

        $zz = array('empnumber' => $this->input->post('empnumber'));
        //$this->db->order_by("surname", "asc");
         $this->datatables->select('date_auto,particulars,earned_VL,aul_VL,balance_VL,aulx_VL,earned_SL,aul_SL,balance_SL,aulx_SL,date_leave,action_taken')
        ->from('tblreport')->where($zz);

        echo $this->datatables->generate();
    }
这是我假设的问题:

从tblreport中选择*其中empnumber=(我的文本框中的empnumber。)

在那里,我从一个文本框中获取一个值到我的视图。但它不起作用。我知道这是错误的。你能帮我解决我的问题吗?多谢各位

<p align="center"> <?php echo $this->table->generate();?></p></div>
<?php foreach ($tblemployee as $row){?> 
<input type="text" name="empnumber" readonly="readonly"  value="<?php echo $row->empnumber;?>"/>
<input type="hidden" name="empnumber" value="<?php echo $row->empnumber;?>"/>

尽可能简单地使用


控制器中

$data['tblemployee'] = $this->model_name->reporttable($id)//assign your data base value to variable 
$this->load->view('your view name',$data )
型号中

public function reporttable($id)
    {
    $query = $this->db->query("select * from tblreport where empnumber = '$id'");
    $result = $query->result_array();
    return $result; // this will return your data as array
}
视图中

<?php 
foreach ($tblemployee as $row)
{
echo $row['id];

}?>
试试这个:

使它更简单

在模型中:

public function reporttable ($id){

  $this->db->select('*');
  $this->db->from('tblreport');
  $this->db->where('empnumber', $id);

  $query =  $this->db->get();
  return $query->return_array(); // use this if so want to return many query if not you can also use first_row('array')
}
在控制器中:

public function function_name (){
  $data['variable_name'] =  $this->model_name->reporttable($id); // change the model_name by your own model where your function reporttable is located and use the variable_name for your view,

  $this->load->view('view_name' , $data); // load the view page you want to display.
}

控制器中

$data['tblemployee'] = $this->model_name->reporttable($id)//assign your data base value to variable 
$this->load->view('your view name',$data )
$data['tblemployee']=$this->model_name->reporttable($id)//将数据库值分配给变量
$this->load->view('your view name',$data)
型号中

public function reporttable($id)
    {
    $query = $this->db->query("select * from tblreport where empnumber = '$id'");
    $result = $query->result_array();
    return $result; // this will return your data as array
}
公共函数报告表($id)
{
$query=$this->db->query(“从tblreport中选择*其中empnumber='$id');
$result=$query->result_array();
return$result;//这将以数组形式返回数据
}
视图中

<?php 
foreach ($tblemployee as $row)
{
echo $row['id];

}?>

请检查此选项,它将帮助您感谢您的回答。我问之前检查了一下。我在那里找不到答案。但是谢谢你的回答。@jbnaron-如果你愿意,我可以给你另一个处理datatable的代码。@buggfixer怎么做,mate?@jbnaron-检查buddythank以获得答案。我知道你的意思,但我想说的是,我想从我的表中选择一些东西,其中我的empnumber等于我想要的id。它是对dataTable的查询。谢谢您的回答。您只需要从URL传递数据,它会自动执行上述代码