我正在尝试从多行添加货币。以下是我的代码。我不确定SUM应该在哪里。
如果可能的话,我还想使用FPDF将结果表格放到PDF格式中。我尝试粘贴我的代码,但无法让它工作,不断给我一个错误,它不是正确的格式。我一直按 CTRL + k 并输入代码,但它没有用;
有什么建议吗?
<?php
session_start(); // start up your PHP session!
?>
<html>
<head>
<meta charset="UTF-8"/>
<title>Accounting Page</title>
<link rel="stylesheet" type="text/css" href="../css/table.css"/>
<script src="../js/table.js" type="text/javascript"></script>
</head>
<?php
error_reporting(0);
$con = mysql_connect("localhost", "root", "rq5f4mkn");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("charitabledb", $con);
$sql = "SELECT * FROM accounting";
$result = mysql_query($sql);
?>
<div id="content">
<div id="blog">
<div id="articles" style="width:692px;padding:0;">
<table width="250" border="1" class="example table-autosort table-autofilter
table-autopage:10 table-stripeclass:alternate table-page-number:t1page table-
page-count:t1pages table-filtered-rowcount:t1filtercount table-
rowcount:t1allcount" id="t1">
<thead>
<tr style="height:35px">
<th class="table-filterable table-sortable:default table-sortable" title="Click
to sort">Date
</th>
<th class="table-filterable table-sortable:default table-sortable"
title="Click to sort">Transaction Type
</th>
<th class="table-filterable table-sortable:default table-sortable"
title="Click to sort">Account
</th>
<th class="table-filterable table-sortable:default table-sortable"
title="Click to sort">Description
</th>
<th class="table-filterable table-sortable:default table-sortable"
title="Click to sort">Amount
</th>
</tr>
</thead>
<tbody>
<?php
while($row = mysql_fetch_array($result))
{
?>
<tr>
<td><?php echo $row['date']?></td>
<td><?php echo $row['transactiontype']?></td>
<td><?php echo $row['account']?></td>
<td><?php echo $row['description']?></td>
<td><?php echo $row['amount']?></td>
<?php
}
mysql_close($con);
?>
</tbody>
<tfoot>
<tr>
<td style="cursor:pointer;"
class="table- page:previous">< <Previous
</td>
<td style="text-align:center;" colspan="1">Page <span id="t1page">1</span> of
<span id="t1pages">11</span></td>
<td style="cursor:pointer;" class="table-page:next">Next > ></td>
</tr>
<tr>
<td colspan="3"><span id="t1filtercount">105</span> of
<span id="t1allcount">105</span> rows match filter(s)
</td>
</tr>
</tfoot>
</table>
答案 0 :(得分:0)
如果您只是总计表中的所有值:
mysql_query("SELECT SUM(amount) FROM accounting");