How to display data only once by using two different tables in codeigniter

I am preparing register that input from date and to date...That display the entries made by the user from date and to date...I want to display voucher no,billdate,qty,amount(present in purchase bill table) and product name(present in purchaseitem table) i want to print the product name on the same row according to the billno..(For this i am using group concat)...My problem is all the datas are displaying multiple times..I don't know where is the error in my code..What changes have to be done on my code to display the data only once..Below i have attached my code..Help me

Controller Code:

$this->db->where('date >=', $newDate);
        $this->db->where('date <=', $newDate2);
        $this->db->select('*');
        $this->db->from('purchasebill');
        $this->db->order_by("voucherno", "asc");
        $this->db->join('parmaster','parmaster.Pcode = purchasebill.partyname','left outer');
        $this->db->select('GROUP_CONCAT(Prdtname)as itemname',false);
        $this->db->order_by('vno','asc');
        $this->db->group_by('vno,billno');
    $this->db->from('purchaseitem');


    $query = $this->db->get('')->result_array();    
    $data ['query']= $query;

View code:

  <?php $rowcount = 1 ?>                            
                                <?php foreach ($query as $row): ?>

                                        <tr>
                                            <td><?=$rowcount;?></td>
                                            <td><?=$row['voucherno'];?></td>
                                            <td><?=$row['date'];?></td>
                                            <td><?=$row['PName'];?></td>
                                            <td><?=$row['sqty'];?></td>
                                            <td><?=$row['billtot'];?></td>
                                            <td><?=$row['itemname'];?></td>
                                            <?php $rowcount +=1?>
                                            <br>
                                            <?php endforeach ?> 
                                        </tr>

I think the datas are printing multiple times because i have used two queries but passed on the same variable $data..Is there is any possibility to load multiple query result on the same view page..???


Solution 1:

$this->db->where('date >=', $newDate);
    $this->db->where('date <=', $newDate2);
    $this->db->select('purchasebill.*,GROUP_CONCAT(parmaster.Prdtname)as itemname');
    $this->db->from('purchasebill');
    $this->db->join('parmaster','parmaster.Pcode = purchasebill.partyname','left outer');
    $this->db->order_by('vno','asc');
    $this->db->group_by('vno,billno');


$query = $this->db->get()->result_array();    
$data ['query']= $query;