Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting newest message from user
    primarykey
    data
    text
    <p>How can I get the newest message from the person who sends a user a message?</p> <p>Right now it's showing...</p> <pre><code>first_name last_name This is the newest message I sent you 2012-08-11 14:23:38 first_name last_name test 2012-08-11 14:20:35 &lt;?php echo '&lt;div id ="inbox_name"&gt;Name&lt;/div&gt;&lt;div id="inbox_message"&gt;Message&lt;/div&gt;&lt;div id="inbox_time"&gt;Time&lt;/div&gt;&lt;div id="inbox_line"&gt;&lt;/div&gt;'; $query = mysql_query("SELECT * FROM `private_messages` WHERE `to_id`=$session_user_id ORDER BY `time_sent` DESC") or die("Error connecting to database. Please try again later."); while ($row = mysql_fetch_array($query)) { $to_id = $row['to_id']; $from_id = $row['from_id']; $message = $row['message']; $time= $row['time_sent']; $message_information = mysql_query("SELECT * FROM `sentrl_users` WHERE `id`=$from_id LIMIT 1"); while ($row_information = mysql_fetch_array($message_information)) { $first_name = $row_information['first_name']; $last_name = $row_information['last_name']; $username = $row_information['username']; echo '&lt;div id="inbox_information"&gt;&lt;div id="recieved_name"&gt;'. $first_name . ' ' . $last_name .'&lt;/div&gt;&lt;div id="recieved_message"&gt;'. $message .'&lt;/div&gt;&lt;div id="recieved_time"&gt;'. $time .'&lt;/div&gt;&lt;/div&gt;'; } } ?&gt; </code></pre> <p>I tried using limit 1, but that didnt work. I'm trying to just get the newest message WITHOUT duplicating the <code>first_name</code> and <code>last_name</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload