这是我的控制器和模型。
请在查看页面abc
中为我提供帮助,以在表格字段中显示特定的列。
public function abc()
{
$n=$this->uri->segment(3);
$svc['id'] =$this->Admin_model->getallserv($n);
$this->load->view('abc',$svc);
}
public function getallserv($n)
{
$sql = "select * from services where id=$n";
$query = $this->db->query($sql);
return $query->result();
}
答案 0 :(得分:0)
- Update `$query->result()` to `$query->row_array()`
- Then result will be like `array('column_name' =>
'value','column_name' => 'value'.........)`
- assign to `$svc` and in view you can access values like $svc->column_name
public function abc()
{
$n=$this->uri->segment(3);
$svc =$this->Admin_model->getallserv($n);
$this->load->view('abc',$svc);
}
public function getallserv($n)
{
$sql = "select * from services where id=$n";
$query = $this->db->query($sql);
return $query->row_array();
}