表格格式的分页问题 [英] Pagination issues with table format
问题描述
有人可以帮助我吗?我正在尝试解决这个问题. 我的表以前是一个普通表,我使用下面的代码来调用语句表中的值,它对我来说非常理想,但是我试图将普通表转换为分页表,如下图所示.
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" ? "$ " . number_format($amount, 2) : ""; ?></td>
<td data-title="Credit" class="numeric"><?php echo $tx_type == "credit" ? "$ " . 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 ? . number_format($amount, 2)"].'</td>
<td>'.$row["tx_type == credit ? . number_format($amount, 2)"].'</td>
推荐答案
问题出在试图确定数组键字符串中事务类型的方式上.
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' ? ' ' . number_format($row['amount'], 2) : "") . '</td>
<td>' . ($row["tx_type"] == 'credit' ? ' ' . number_format($row['amount'], 2) : "") . '</td>
我还假设amount
也存储在$row
内;如果要像示例中那样将其静态化,只需将$row['amount']
替换为$amount
即可.
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
];
这篇关于表格格式的分页问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!