Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.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 按字段分组结果_Php_Mysql_Codeigniter - Fatal编程技术网

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'];
}