问题
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