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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.