我的控制器
public function notification()
{
$id = $this->session->userdata('userID');
$data['results'] = $this->lawmodel->notificationModel($id);
$data['content'] ='contact_form';
$this->load->view('includes/template2',$data);
}
我的模特
function notificationModel($id){ $this->db->select('*'); $this->db->where('requestedID',$id); $query = $this->db->get('request'); return $query->result();
}
我的观点
<h1>Sample!</h1>
<?php
foreach($results as $row)
echo $row->challengerID;
?>
&GT;
此代码的输出为
样品! 38 42
我的问题是,由于有两个输出38和42,我如何单独获得该输出,以便我可以使用每个输出在数据库中查询
实施例 (这只是一个样本) 38是上述代码的输出之一..
function notifyIDUser( 38 ){ $this->db->where('user_id', 38 ); $query = $this->db->get("user"); return $query->result();
Im just new in codeigniter and i need to finish my project after new year..:(
抱歉,我的英语不够好......
答案 0 :(得分:0)
您可以在控制器中处理“notifyIDUser”,如下所示
public function notification()
{
$id = $this->session->userdata('userID');
$data['results'] = $this->lawmodel->notificationModel($id);
foreach($data['results'] as $row) {
$this->model_name->notifyIDUser($row->challengerID);
}
$data['content'] ='contact_form';
$this->load->view('includes/template2',$data);
}