0

My task is i want to display Sno,bill date,bill no partyname,item name,Qty,Amoumt,Disc %,DiscAmt and bill amount..all other columns are present in purchase bill array except itemname and i want to display itemname according to their bill no, my problem is all the columns are repeatedly printing according to the itemname...but i want to display itemname according to the items in one column and all other columns in one row..enter image description here Controller code:

    if($this->input->post('selected'))
    {
        if($name = $this->input->post('businessType'))
        {
            $this->db->where('date >=', $newDate);
            $this->db->where('date <=', $newDate2);
            $this->db->where('PName',$name);
            $this->db->select('*');
            $this->db->from('purchaseitem');
            $this->db->order_by("billno", "asc");
            $this->db->join('purchasebill', 'purchasebill.no = purchaseitem.billno','left outer');
            $this->db->join('parmaster','parmaster.Pcode = purchasebill.partyname','left outer');
            $query = $this->db->get('')->result_array();
            $data['query'] = $query;
            $this->load->view('Receipt_View', $data);
         }
    }

View page code:

    <th>Bill No</th>
    <th>Bill Date</th>
    <th>Party Name</th>
    <th>Item Name</th>
    <th>Qty</th>
    <th>Amount</th>
    <th>Disc %</th>
    <th>Disc Amt</th>
    <th>Bill Amount</th>
    <!--<th>Bill Amount</th>-->
</tr>
</thead>
<br>
<tbody>
<?php $rowcount = 1 ?>                          
<?php foreach($query as $row): ?>
    <tr>
        <td><?=$rowcount;?></td>
        <td><?=$row['no'];?></td>
        <td><?=$row['date'];?></td>
        <td><?=$row['PName'];?></td>
        <td><?=$row['Prdtname'];?></td>
        <td><?=$row['Qty'];?></td>
        <td><?=$row['amount'];?></td>
        <td><?=$row['Disper'];?></td>
        <td><?=$row['Disamt'];?></td>
        <td><?=$row['Grdtot'];?></td>
  <?php $rowcount +=1 ?>
  <?php endforeach ?>

<br>
    </tr>
Lelio Faieta
  • 6,457
  • 7
  • 40
  • 74
  • I really am confused about what actually you want, but as far as I understood, this looks similar : https://stackoverflow.com/a/3492563/9144250 – elpidaguy Oct 31 '18 at 08:37
  • i just want to display all of the item entries according to the bill no rest of the datas will be printed once – laavanya dharani Oct 31 '18 at 08:47
  • If you want to show one row for unique bill number which will show itemnames in single column, you can use groupby query to group results per bill number Refer: https://www.w3schools.com/sql/sql_groupby.asp – elpidaguy Oct 31 '18 at 08:54
  • but i have one problem i am not getting bill number from the user..i am just preparing a register that gets input as date..from that date i want to display the details – laavanya dharani Oct 31 '18 at 08:58
  • so date is your unique key here...use date to group your data by...your query remains the same...add one more line to groupby by date...and then in your view....change foreach as per your need... – elpidaguy Oct 31 '18 at 09:02
  • But there is a chance of having more than one bill on the same day – laavanya dharani Oct 31 '18 at 09:07
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/182843/discussion-between-laavanya-dharani-and-exabytes-js). – laavanya dharani Oct 31 '18 at 09:07

0 Answers0