Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何根据where条件对concat进行分组,并在单个div中显示相同的数据?_Php_Mysqli - Fatal编程技术网

Php 如何根据where条件对concat进行分组,并在单个div中显示相同的数据?

Php 如何根据where条件对concat进行分组,并在单个div中显示相同的数据?,php,mysqli,Php,Mysqli,我试图显示一个日期中发生的所有事务,如下所示。12-12-12, 15-9-20. 现在它在单独的分区中显示每个事务。但我想显示同一分区中当天发生的所有事务。作为linke,我在12-12-12中有五个事务 mysql> select * from all_trans; +--------+---------+------------+------------+--------------+------------+ | row_id | user_id | trans_date | d

我试图显示一个日期中发生的所有事务,如下所示。12-12-12, 15-9-20.

现在它在单独的分区中显示每个事务。但我想显示同一分区中当天发生的所有事务。作为linke,我在12-12-12中有五个事务

mysql> select * from all_trans;
+--------+---------+------------+------------+--------------+------------+
| row_id | user_id | trans_date | debit      | credit       | other      |
+--------+---------+------------+------------+--------------+------------+
|      1 |      30 | 2015-11-09 | vcvv#      | dfdsfsd#     | df+-       |
|      2 |      30 | 2015-11-09 | tertreter# | tferterte#   | gdfgdf+-   |
|      3 |      25 | 2012-12-12 | 2000#      | 200#         | dfsdfsd+   |
|      4 |      30 | 2015-11-16 | dffdfgd#   | dfsdfdsfds#  | fsdfsd+c   |
|      5 |      30 | 2015-11-16 | dffdfgd#   | dfsdfdsfds#  | fsdfsd+c   |
|      6 |      30 | 2015-11-16 | fdsfsd#    | dgdfg#fsdfsd | dfsd+      |
|      7 |      33 | 2015-11-16 | dfsdfds#   | dfgdfgfd#    | fdvgfdgdf+ |
+--------+---------+------------+------------+--------------+------------+
我的问题是:

select *, group_concat(trans_date) from all_trans where user_id=$user_id;
我的剧本:

<div class="row">
    <?php
    $sql = " select *, group_concat(trans_date) from all_trans where user_id=$user_id;";
            $insert = mysqli_query($conn, $sql);
            $row_result = mysqli_num_rows($insert);
            if($row_result > 0){
                    while ($result = mysqli_fetch_array($insert)) {
    ?>

    <div class="#">
            <ul>
                    <li>

                            <h4>
                            <?php echo '<b>'.$result['trans_date'].'</b>';
                            ?>

                            </h4>


                            <div class="row">
                                    <div class="col-sm-4">
                                            <div class="debit">
                                                    <h4> <b>Debit</b>
                                                    <div class="total-transaction">

                                                            <li> <?php echo $result['debit']; ?></li>

                                                    </div>
                                                    </h4>

                                            </div>

                                            </div> <!-- end col4 -->
                                            <div class="col-sm-4">
                                                    <div class="credit">
                                                            <h4>
                                                            <b>Credit</b>
                                                            <div class="total-transaction">
                                                                    <li><?php echo $result['credit']; ?></li>
                                                            </div>
                                                            </h4>

                                                    </div>

                                                    </div> <!-- end col4 -->
                                                    <div class="col-sm-4">

                                                            <div class="other">
                                                                    <h4> <b>Other
                                                                    <span class="fl-left">
                                                                            <div class="view-button">
                                                                                    <form action="" method="POST" >
                                                                                            <button type="button" class="btn btn-primary btn-update">Update</button>

                                                                                            <button type="button" class="btn btn-danger">Delete</button>
                                                                                    </form>

                                                                            </div>
                                                                    </span>
                                                                    </b>
                                                                    <div class="total-transaction">

                                                                            <li> <?php echo $result['other']; ?></li>
                                                                    </div>
                                                                    </h4>

                                                            </div>

                                                            </div> <!-- end col4 -->


                                                            </div> <!-- end row -->
但它只显示了一笔交易,而不是一笔div下的全部5笔交易

我不知道我的查询将是什么,以显示所有事务在同一div中具有相同的日期

任何帮助都会对我很好。谢谢你试试这个

select *, CONCAT(trans_date , ' ') from all_trans where user_id=$user_id;

请不要链接到您的代码,而是将其添加到问题中。隔离尽可能多的数据以减少大小。谢谢您的建议