[英]How to count no of rows of a table in codeigniter and display in view with other details?
Hello everyone i have a problem please help me 大家好我有问题请帮助我
I have two table one is Subject and other is question 我有两个表,一个是主题 ,另一个是问题
fields in Subject table is 主题表中的字段是
+------+-----------+-----------+
| id | name | set_id |
+------+-----------+-----------+
in Question table 在问题表中
+------+-----------+-----------+-----------+---------------+
| id |question | answer | subject |
+------+-----------+-----------+-----------+---------------+
I want to display details like below image 我想显示下图所示的详细信息
How to do this please help me your help would be appreciated. 如何做到这一点,请帮助我,您的帮助将不胜感激。
function subjectlist(){
$val=array('a.id','a.name','a.set_id','b.set_name');
$where=array('user_id'=>$this->session->userdata['logged_in']['id']);
$sub=$this->login->get_join($val,'','b.id=a.set_id',$where,'subject as a','q_set as b');
$count_all=array();
foreach($sub as $count) {
$where1=array('subject_id'=>$count->id);
$count_all[]=array('id'=>$count->id,'name'=>$count->name,'set_id'=>$count->set_id,'set_name'=>$count->set_name,'all_val'=>$this->login->count_val($where1,'question'));
}
$data['subject']=$count_all;
$this->load->view('i_user/subject_list',$data);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.