【问题标题】:I want to show amount by category credit or debit I only receive credit amount我想按类别显示金额 贷方或借方 我只收到贷方金额
【发布时间】:2019-06-24 18:11:11
【问题描述】:

我的表格中有一个金额列,我想按贷方或借方类别显示该金额我只收到贷方金额。

控制器

 <?php foreach($modResult as $voucher):?>
            <tr>
              <th>Voucher No.</th>
              <th>Voucher Amount BY CR.</th>
              <th>Voucher Amount BY DR.</th>
             <tr>

        <tr> 
         <td><?php echo $voucher['voucher_no'];?></td>
         <td><?php echo $voucher['voucher_amount'] = $voucher['voucher_transaction_type']=='CR' ? $voucher['voucher_amount'] : '';?></td>

 <td><?php echo $voucher['voucher_amount'] = $voucher['voucher_transaction_type']=='DR' ? $voucher['voucher_amount'] : '';?></td>
          </tr>
     <?php endforeach; ?> 

型号

            $this->db->select('*');
            $this->db->from('ts_voucher');

            $this->db->where('voucher_category','cash_receipt');
            $this->db->or_where('voucher_category','cash_payment');

           $query=$this->db->get();
           return $query->result_array();

如何在 Voucher Amount BY DR 列中显示 DR 值

【问题讨论】:

  • 类别在另一个表中?
  • 同一表中没有类别@DanishAli

标签: php mysql sql codeigniter


【解决方案1】:

这样做

<td><?php echo $voucher['voucher_transaction_type'] == 'CR' ? $voucher['voucher_amount'] : '';?></td>

 <td><?php echo $voucher['voucher_transaction_type'] == 'DR' ? $voucher['voucher_amount'] : '';?></td>

阅读更多conditional operators

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-11
    • 1970-01-01
    相关资源
    最近更新 更多