【问题标题】:php/mysql Data Id into header tablephp/mysql 数据 ID 到头表中
【发布时间】:2017-11-02 12:08:22
【问题描述】:

作为 PHP/MySQL 的新手。

我在过去三周内使用 PHP/MySql,它融合在一起很棒,但这是从 Mysql 数据到 php 的大量学习。

我正在尝试将数据 Id 作为表获取到 Header 中的问题,但不知何故它不起作用,并且根本不显示或出错。

就像所有的“交易类型”进入标题或 TR,然后“每个组金额”进入表格正文或 TD

这是代码

<table class="table table-condensed table-bordered table-striped table-hover dt-responsove wrap" cellspacing="0" >
    <thead>
        <th  Class="table-header-total">
            <?php
               while (($grouptotalrow = mysqli_fetch_array($grouptotalorder1, MYSQLI_BOTH)) != NULL) {
                ?>  
               <td  class="table-smaller-text-bolder"><?php echo $grouptotalrow["transaction_type"];?></th>
                <?php
                }
                mysqli_free_result($grouptotalorder1);
            ?>    
            <?php
               while (($grouptotalrow = mysqli_fetch_array($grouptotalorder, MYSQLI_BOTH)) != NULL) {
                ?>  
               <td  class="table-smaller-text-bolder"><?php echo $grouptotalrow["Each_group_Amount"];?></td>
                <?php
                }
                mysqli_free_result($grouptotalorder);
            ?>    
        </tr>

    </thead>
    <tbody>
    </tbody>
</table>   

这是一个数据库

SELECT 
    settlement_id,
    total_amount,
    transaction_type,
    amount_description,
    SUM(amount) AS `Each_group_Amount`
FROM
    settlements
WHERE
    transaction_type = 'order'
        OR transaction_type = 'Refund'
        OR transaction_type = 'ServiceFee'
        OR transaction_type = 'other-transaction'
        OR transaction_type = ''

GROUP BY settlement_id ASC , amount_description ASC

Screenshot of mysql workbench

这个结果不是我要找的

Result in webpages

【问题讨论】:

标签: php mysql mysqli


【解决方案1】:

更新:

我决定让自己从 PC/PHP 的东西上休息几个小时(更像是头脑清醒)然后回来,最后,我把它修好了。

这是我写的代码

<?php

            echo '<table class="table table-condensed table-bordered table-striped table-hover dt-responsove wrap" cellspacing="0">';
            echo '<tbody>';
            echo '<tr>Break down of transation sale</tr>';
            $resultTranactiontypegroup = mysqli_query($conn,$sqlbreakdowntransaction_type);
            while (($row1 = mysqli_fetch_array($resultTranactiontypegroup, MYSQLI_ASSOC)) != NULL) {

                echo '<tr>';
                echo '<th class="table-header-total">' . $row1['transaction_type'] . '</th>';
                echo '<td class="table-smaller-text">' . $row1['Each_group_Amount'] . '</td>';
                echo '</tr>';
            }
            mysqli_free_result($resultTranactiontypegroup);
            echo '</tbody>';
            echo '</table>'
            ?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-24
    • 2015-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-28
    • 2014-05-25
    相关资源
    最近更新 更多