Creating an online chat with PHP

Asked

Viewed 609 times

0

I’m trying to create a chat like facebook, I’d like to know how it works.

In it we talk and disconnect and after reconnecting is displayed the history of old messages in order perfectly, how to do this?

  • Your question already has 3 votes to close, including mine. She is very confused and vague. I’ve read it a few times and I don’t quite understand what it is you’re asking about. You can edit it to make it clearer?

  • opa sorry Victor, cabei de editar ver se vc pode ajudar me agora, thanks desde ja rs.

  • Keep in mind that Facebook has a server that supports a massive amount of users and registrations... If that’s not a problem for you, then start crafting a table that contains id_user_post_message, id_user_receive_message, message, date otherwise it is programming logic.... At the time of the history query just make a select with order by date

  • @Juniors Actually I think the question has become even more vague than before. Before at least you gave an idea of what your database was like, now not even that. :(

  • a great answer, yes I could use the order by date however I would be listing the person’s msg and how I would list mine also in correct order ex: Carla said: hi

1 answer

1

I believe that you are forgetting to keep a column with the date/time record of the messages in order to sort by it, another option is simply sort by the table id, but I find the first option much better. Control by the user’s Session which time the last query to the bank to bring only new messages and reduce their bandwidth consumption.

A good advice would also be to invest in some reverse ajax technology, or even a simple websocket (there are some examples ready on the web that you can customize well) so your system would only query when really needed and not from time to time. I’ve done a little chat in javascript (very basic, no bank had) using websockets and was very cool.

  • thanks dear great reply... + for example I made up by datahr would list all blz, more let’s assume user left, and back how to re-list the msg in order again? for example on facebook when we connect again it lists the msg in order all right in order :p

  • 1

    @Juniorvieira ai you would need to add ORDER BY criteria in your SQL... could you put something you already have ready? It would be easier for other people to help.... So I also believe that your question can be reopened by getting more objective.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.