Jump to content

[SOLVED] Ajax/php Chat


cpd

Recommended Posts

Hello,

 

I have created an Ajax/php chat however i have a problem because its not exactly what i want.

 

Currently, my chat sneds off the http request and the php returns the last 80 messages entered into the database. This means that there are constantly 80 messages being output into the chat.

 

I want to change this so that when the chat loads in the users browser, a 20 message buffer is output. The last 20 messages in the database. From then on, any new messages submitted to the database are simply "added" on top of the current ones in the chat.

 

I have a feeling its something to do with taking whats already in the chat and just adding the comment on through javascript however, i have no idea how to check if the comments in the database have already been output or not.

 

Every chat i have seen does this and its very similar to Messenger or Skype whereby the comments are just added.

 

So to conclude id like to know how to:

 

1) tell if the comments have already been output and if not to output them.

 

2) the best way to output the new comments

 

Regards

Chris

 

Thank you to anyone who helps and solves my currently dilema because i have quite literaly spent months on trying to figure this out and ive revised previous scripts etc etc and i just cant figure it out.

Link to comment
https://forums.phpfreaks.com/topic/170054-solved-ajaxphp-chat/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.