Im Beginer in Codeigniter I have table
table_a:
I want create detail data only about 'STEVE' like:
but I can't get all data by NAME.Only data By ID.
This last try code in My Model:
public function detail($id){
$where = array('id' => $id);
$name = 'name', $name;
$data['sales'] = $this->people->detail($where,'table_a')->row();
$data['saless'] = $this->people->getdatabyname($name);
$this->template->display('test/detail',$data);
}
This My Controller:
function detail($where,$table){
return $this->db->get_where($table,$where);
}
function getdatabyname($name){
$this->db->select('*');
$this->db->from('table_a');
$this->db->where('table_a.name', $name);
return $this->db->get()->result();
}
Please Help
//if you have $id is table_a primary key id then you can get by this:
//controller
function detail($id){
$data=array();
$this->load->model('model_name');
$table_a_data= $this->model_name->get_table_a_by_id($id);
$data['steve']=$this->model_name->get_steve_by_name($table_a_data->name);
$this->template->display('test/detail',$data);
}
//model
function get_table_a_by_id($id){
return $this->db->where('id',$id)->get()->row_array();
}
function get_steve_by_name($name){
return $this->db->where('name',$name)->get()->result_array();
}
//if you don't have id then use join to get data
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.