如何在PHP Codeigniter中仅显示一次数据

时间:2018-10-31 06:41:40

标签: php mysql codeigniter

我的任务是我想显示Sno,账单日期,账单上没有宴会方名称,商品名称,数量,余额,光盘%,DiscAmt和账单金额。.除项目名称外,所有其他列都存在于采购账单数组中,我想根据他们的帐单号显示项目名称,我的问题是所有列都根据项目名称重复打印...但是我想根据一列中的项目以及一行中所有其他列显示项目名称。{{3} } 控制器代码:

    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);
         }
    }

查看页面代码:

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

0 个答案:

没有答案