How to do searching in PHP and AJAX?

AJAX chat script help?

  • So i am new to AJAX but pretty familar with php and javascript. I am trying to make a chat script but I am stuck on the find new chat partner part. The chat script will be one on one chat and when someone clicks "Find" I want it to search the database for other users that are looking for someone. So I thought I will make a column in the sql database that will be called "search".. yes if they are searching no if they arent. When they do find someone I thought i will have php make a new table for the chat messages to be held. The problem is I don't want duplicate tables made. How can I make it so that only 1 message table is made

  • Answer:

    You should not be creating database tables on the fly during operation. Tables are something you create as part of your database design, and you create them once and leave them alone. Instead, have a table which stores all the chat messages, and have a column which associates the row with a particular user, etc.

Janice B at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

You don't want to create a temporary table...the resultset of your query IS a temporary table already and not one you'd want (or need) to retain indefinitely. All you want is something like SELECT userID FROM someTable WHERE searching = "yes" This would give you everyone currently searching at that moment. You could then use any number of methods to randomly pick one out of that set.

Just add "room" in your chat table! Have "common" for everyone. Allow people to create a room "name". Join me in my "room" and you just update the room from "common" to "myroom" !

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.