如何显示后跟相同ID的邮件?

时间:2017-08-31 02:04:31

标签: php mysql

人们,我需要一个接一个地列出聊天消息,我试着做这个脚本,但结果不同。

<?php
openConnection();
$stmt2 = $mysqli->prepare("SELECT texto, who FROM system_chat WHERE userid=? ORDER by id ASC");
$stmt2->bind_param("i", $_SESSION["userid"]);
$stmt2->execute();
$stmt2->store_result();
if($stmt2->num_rows >= 1) {
    $stmt2->bind_result($texto, $who);
    while($stmt2->fetch()) {
        if($who == "Admin") {
            echo "
                <div class='list-group-item media'>
                    <div class='pull-left'>
                        <img class='avatar-img' src='".PATH_THEME."/demo/img/profile-pics/1.jpg' alt=''>
                    </div>
                    <div class='media-body'>
                        <div>
                            <div class='messages__item'>
                                {$texto}
                            </div>
                        </div>
                    </div>
                </div>

            ";
        } else if($who == "User") {
            echo "
                <div class='list-group-item media'>
                    <div class='pull-right'>
                        <img class='avatar-img' src='".PATH_THEME."/demo/img/profile-pics/8.jpg' alt=''> 

                    </div>
                    <div class='media-body'>
                        <div>
                            <div class='messages__item'>
                                {$texto}
                            </div>
                        </div>
                        <small class='ms-date'><i class='zmdi zmdi-time'></i> 20/02/2015 at 09:30</small>
                    </div>
                </div>
            ";
        }
    }
}
$stmt2->close();
$mysqli->close();
?>

上面代码的结果如下图所示 enter image description here

但我需要的是这种方式,如下图所示

enter image description here

我没有mysql和php

0 个答案:

没有答案