Php 按字段分组结果
我正在为一个网站建立一个消息传递系统,但我希望它有一个即时消息应用程序的感觉。 我的桌子结构如下:Php 按字段分组结果,php,mysql,codeigniter,Php,Mysql,Codeigniter,我正在为一个网站建立一个消息传递系统,但我希望它有一个即时消息应用程序的感觉。 我的桌子结构如下: <!-- language: lang-none --> id R_id = Reciever's id S_id = Sender's Id message read = 0 if unread, 1 if read post_time conv_id = conversation id 也许是这样的 // Presuming you want the m
<!-- language: lang-none -->
id
R_id = Reciever's id
S_id = Sender's Id
message
read = 0 if unread, 1 if read
post_time
conv_id = conversation id
也许是这样的
// Presuming you want the most recent ones first
$q = mysql_query("SELECT message FROM `TABLE` WHERE `R_id`='USERNAME_HERE' ORDER BY `post_time` DESC");
while ($row = mysql_fetch_array($q)) {
echo "<li>Message: " . $row['message'];
}
老实说,我不太确定你在问什么,所以这是我能做的最好的了。你有什么问题,你试过什么?好的。您的问题是什么?@Xeon06,我尝试了按S_id字段分组我希望能够对来自用户的消息进行分组,而不是为每个新消息显示单独的行我正在尝试创建一个类似于FaceBook的系统我希望能够对来自用户的消息进行分组,而不是为每个新消息显示单独的行
// Presuming you want the most recent ones first
$q = mysql_query("SELECT message FROM `TABLE` WHERE `R_id`='USERNAME_HERE' ORDER BY `post_time` DESC");
while ($row = mysql_fetch_array($q)) {
echo "<li>Message: " . $row['message'];
}