展开具有相同值的行PHP SQL

时间:2018-08-29 10:50:49

标签: php mysql

我想要的是显示相同值的行。输出如下:

enter image description here

这是数据库:

enter image description here

如您在图像上看到的,表:25应该基于数据库在一张卡中有2行。

代码如下:

$statement_select = $pdo_connection->prepare("SELECT * FROM orders GROUP BY user_id");
$statement_select->execute();
$result = $statement_select->fetchAll();
 if ($result) {

foreach ($result as $row) {
    $data_user_id = $row['user_id'];
    $data_ordered_product = $row['ordered_product'];
    $data_quantity = $row['quantity'];
    $data_size = $row['size'];
    $data_pickup_time = $row['pickup_time'];

   echo <<<EOD
<div class="cards">
    <div class=card_1>
        <div class="card_header">
            <p>TABLE: $data_user_id</p>
        </div>
        <div class=table_dashboard>
    <div class=table_row>
        <div class=column1>
                    <b>Item:</b>
        </div>
        <div class=column2>
                    <b>Qty:</b>
        </div>


        <div class=column1>
                    <p>$data_ordered_product($data_size)</p>

        </div>
        <div class=column2>
                    <p> $data_quantity</p>
        </div>  
        </div>
    </div>
 //disregard
    <div="table_footer">
        <p align="right"><b>Time:</b> $data_pickup_time &nbsp;&nbsp;</p>

    <div class="group_options_1"><button>DONE</button></div>
    </div>
    </div>
 EOD;
    }
}

感谢您的友善考虑:)

0 个答案:

没有答案