Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7544537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:41:47+00:00 2026-05-30T08:41:47+00:00

$query = mysql_query(SELECT *, MAX(date_time) FROM messages WHERE user_to=’$current_user’ OR user_from=’$current_user’ GROUP BY conversation

  • 0
$query = mysql_query("SELECT *, MAX(date_time) FROM messages 
                      WHERE user_to='$current_user' OR user_from='$current_user'
                      GROUP BY conversation 
                      ORDER BY date_time DESC LIMIT 0,5") or die(mysql_error());

echo $message['MAX(date_time)'];

How can I display the column ‘content’ that is in the same row as the date_time being selected here, so the time matches with the message? Would it be something like

echo $message['MAX(content)'];

I am trying to have ‘messages’ in groups (called conversations) and I want to display the most recent message. It is currently displaying the most recent time but not the most recent message.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:41:48+00:00Added an answer on May 30, 2026 at 8:41 am

    If your table has an autoincrement id column to use as the message id, then the highest id value should also be the latest message in the conversation

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my code: $query = mysql_query(SELECT * FROM books ORDER BY id) or
$query = mysql_query(SELECT * FROM news WHERE id = '{$_GET['id']}'); $news = mysql_fetch_assoc($query); $sql84
$result = mysql_query(SELECT * FROM project ORDER BY projectid); while($row = mysql_fetch_array($result)) { return(array($row['projectid'],
I have a MySQL query SELECT * FROM 'redirect' WHERE 'user_id'= \''.$_SESSION['user_id'].' \' ORDER
say I have this $result = mysql_query('SELECT views FROM post ORDER BY views ASC');
The sql query: select id,title from blog_post inner join (select object_pk, max(submit_date) from django_comments
$result = mysql_query(SELECT * FROM media WHERE path = '$target'); if($row = mysql_num_rows($result)==1) {
function showFields($selClient) { $result = mysql_query(SELECT * FROM project WHERE projectid = $selClient); $values
include(conn.php); $result = mysql_query(SELECT * FROM sggame); while($row = mysql_fetch_assoc($result)); { $id = $row['id'];
Are they less vulnerable to SQL injection than doing stuff like mysql_query(SELECT important_data FROM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.