duanjiaoxi4928 2019-01-31 10:00
浏览 47

我想按类别信用卡或借记卡显示金额我只收到信用额度

I have one amount column in my table and I want to show that amount by category credit or debit I only receive credit amount.

Controller

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

Model

            $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();

How I can show DR value in Voucher Amount BY DR column

  • 写回答

1条回答 默认 最新

  • dongxin5054 2019-01-31 10:09
    关注

    Do like this

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

    Read more conditional operators

    评论

报告相同问题?

悬赏问题

  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思