Chat code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Limno
    New Member
    • Apr 2008
    • 92

    Chat code

    Hi all,
    can anyone suggest me, how to create my database for chat code as like gtalk.

    msgid
    user1
    user2
    date
    time
    msg
    msgby

    but i cant display their messaged data as

    user1:hi
    user2:how r u?
    user1:i m fine, what abt u?

    I dont knw how to fetch their data

    now my code displaying

    on user1 window


    user1:hi
    user1:i m fine, what abt u?

    on user2 window

    user2:how r u?

    Anyone help me plz

    Thanks in Advance
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    What have you tried so far?
    This looks like a fairly straight-forward SELECT to me. You just need to select rows where the user fields match with the users that are supposed to be a part of the chat.


    Also, there is a better way to design the database, but it is a lot more complicated. I wouldn't suggest it until you have a good understanding of how to do SELECTs, as it involves multiple table joins.

    In essence, it looks something like this:
    [code=text]+------+ +------------+ +--------------+
    | user | | user_convo | | conversation |
    +------+ +------------+ +--------------+
    | id |>-| | convo_id |>|->| convo_id |
    | name | |>| user_id | | | created |
    +------+ | +------------+ | +--------------+
    | |
    | +------------+ |
    | | message | |
    | +------------+ |
    | | msg_id | |
    \| user_id | |
    | convo_id |/
    | text |
    | sent_at |
    +------------+[/code]
    But like I say, the SELECTS for this database would be far more complex than the one you are dealing with now.

    Comment

    • Limno
      New Member
      • Apr 2008
      • 92

      #3
      Hi Alti,

      Can you give me any send me any sample code, so that i can understand how to do this project...

      Thanks in Advance

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        Why don't you start by showing us what you have done so far. You say you had already made code that partially showed what you wanted it to? Show us how that looks and we will move on from there.

        And please, post "snippets" (the important parts) of the code. - People tend to want to post every single line; sometimes hundreds of them. That is not necessary. We only need the parts that have anything to do with the problem. Thanks :)

        Comment

        Working...