Monday 15 September 2014

php - AJAX Chat - ORDER BY date, time (Messages appear from bottom, and the toppest will get deleted)? -


I have a chat application that I am developing:

The problem is, I'm limiting the results of messages to up to 30 messages. I want to overwrite new messages, so the oldest messages will be deleted.

But for some reason, the following messages, which are new, are deleted in return?

I am ordering from date, time:

  SELECT * message order, time ASC limit 30   

Inside the loop:

  echo & lt; Li & gt; & Lt; Div class = "message" & gt; & Lt; P & gt; '. $ Line ['message']. ' & Lt; / P & gt; & Lt; Span class = "user-meta" & gt; '. $ Line ['username']. ' & Lt; / Span & gt; & Lt; Span class = "time-meta" & gt; '. $ Line ['time']. ','. $ Line ['date']. ' & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Li & gt; ';   

Any thoughts?

select
 from  (select message, date Date, time limit 30) As per main order, time asc    

No comments:

Post a Comment