-2

複数の行から一緒に通貨を追加しようとしています。以下はこれまでの私のコードです。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">&lt; &lt;Previous
                    </td>

                    <td style="text-align:center;" colspan="1">Page <span id="t1page">1</span>&nbsp;of
                        <span id="t1pages">11</span></td>
                    <td style="cursor:pointer;" class="table-page:next">Next &gt; &gt;</td>
                </tr>
                <tr>
                    <td colspan="3"><span id="t1filtercount">105</span>&nbsp;of
                        <span id="t1allcount">105</span>&nbsp;rows match filter(s)
                    </td>
                </tr>
                </tfoot>
            </table>
4

1 に答える 1

0

テーブル内のすべての値を単純に合計する場合:

mysql_query("SELECT SUM(amount) FROM accounting");
于 2013-03-18T20:04:28.160 に答える