How to calculate group_concat in codeigniter

人盡茶涼 提交于 2021-01-29 08:02:08

问题


I want to groupconcat product name..but it displaying undefined index product name in my view page..I don't know where i am making mistake..please help me to groupconcat product name..

controller code:

$this->db->select('GROUP_CONCAT(prdtname)', false);
$this->db->from('purchaseitem');
$this->db->group_by('vno');
$query1=$this->db->get()->row_array();
$data['query1']= $query1;

I tried groupconcat in sql on my localhost it gives me an expected result..but i don't know where i had done mistake in converting to codeigniter..please help me to resolve this..


回答1:


Controller Code:

$this->db->select('GROUP_CONCAT(prdtname)as itemname',false);
$this->db->from('purchaseitem');
$this->db->group_by('vno');

View page:

<td><?=$row['itemname'];?></td>


来源:https://stackoverflow.com/questions/53238392/how-to-calculate-group-concat-in-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!