dongmangzong8006 2017-10-23 04:31
浏览 15

分页问题与表格式

Can anyone assist me out there. I am trying to solve this issues. my table was a formerly a normal table and i use below codes to call the values on the statement table and it work perfectly for me, but I am trying to convert the normal tables to a pagination tables as shown below the line drawn

NORMAL TABLE = WORK PERFECTLY

<td data-title="Trns Date">'.$row["tdate"].'</td>  
     <td data-title="Description">'.$row["comments"].'</td>  
    <td data-title="Debit" class="numeric"><?php echo $tx_type == "debit" ? "$&nbsp;" . number_format($amount, 2) : ""; ?></td>
     <td data-title="Credit" class="numeric"><?php echo $tx_type == "credit" ? "$&nbsp;" . number_format($amount, 2) : ""; ?></td>
    ================================================================================PAGINATION TABLES:

But Now i trying to convert it to a pagination table due to the large database, i now use the below code to echo the value on the table. it does not gives me any error on the table, but the value does not show. It just leaves space blank.

The last two rows for amount does not show.

<td>'.$row["tdate"].'</td>  
<td>'.$row["comments"].'</td>  This two rows work ok

But the last two rows for amount values does not show the figures it was blank

<td>'.$row["tx_type == debit ? &nbsp; . number_format($amount, 2)"].'</td>
<td>'.$row["tx_type == credit ? &nbsp; . number_format($amount, 2)"].'</td>
  • 写回答

1条回答 默认 最新

  • doubi9531 2017-10-24 10:24
    关注

    The problem is in the way you are trying to decide the transaction type within the array key string.

    Perhaps these two lines can help:

    <td>' . ($row["tx_type"] == 'debit' ? '&nbsp;' . number_format($row['amount'], 2) : "") . '</td>
    <td>' . ($row["tx_type"] == 'credit' ? '&nbsp;' . number_format($row['amount'], 2) : "") . '</td>
    

    Also I assumed the amount is also stored within the $row; if it is intended to be static similarly as in your example, just replace $row['amount'] with $amount and you are set.

    This snippet assumes you are iterating over an array like this:

    $rows = [                                                                       
        array('tx_type' => 'credit', 'amount' => 123345.697),                       
        array('tx_type' => 'debit', 'amount' => 796543.21),
        //... and so on                         
    ];
    
    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用