我運行一個while循環來獲取最新的每個會話的消息,但我得到的錯誤SELECT *,LAST(DATE_TIME)
[18-Feb-2012 21:14:59] PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /path/messages.php on line 44
下面是完整的循環。它在我添加LAST(date_time)和GROUP BY對話之前有效,但我只想在每個對話中顯示最新消息,而不是每個消息。我怎樣才能做到這一點?
<?php
$current_user = user_info('id',1); //get logged in user id
$query = mysql_query("SELECT *, LAST(date_time)
FROM messages
WHERE user_to='$current_user'
ORDER BY date_time DESC
LIMIT 0,5
GROUP BY conversation");
while($message = mysql_fetch_array($query)) {
?>
<li><strong><?php user_info('first_name',0,$message['user_from']); ?> <?php $sender_last_name = user_info('last_name',0,$message['user_from']); ?></strong><span class="message_time"><?php echo time2str($message['date_time']); ?></span><br />
<span class="message_description"><?php echo substr($message['content'],0,50); ?></span></li>
<?php } ?>
謝謝。
不錯.....趕上..... – 2012-02-19 04:24:54