Help Needed In Showing Private Chat Messages

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    solved Help Needed In Showing Private Chat Messages

    Hi friends i am learning php and creating a chat site script
    i am able to show messages from mysql db in chat room but i dont know how to show private messages

    by using this code is smarty

    PHP Code:
    function chat_messages($rid)
    {
       
    $msgs = array();
       
    $query mysql_query("SELECT * FROM chat_messages WHERE room_id = $rid");
       while (
    $msg_list mysql_fetch_assoc($query)){
       
    $msgs[] = $msg_list;
       }
       return 
    $msgs;

    template code

    PHP Code:
    {foreach from=$msgs item=msg}
    <
    div class="{cycle name="class" values="main,main2"}"><a href="../profile.php?id={$msg.user_id}">{$msg.user_name}</a> : {$msg.message}</a></div>
    {/foreach} 
    i am able to show messages in room name general by id 1
    it shows all messages in that room
    i want to show private msgs to user to whom it is being sended privately
    i means if user 1 send private msg to user 2 it shows message to only both of them not to user 3
    while if message is send to all users it shows to all i hope u understand what i said
    ComputerForumz - Latest Tech News


    Mobbest.tk-Free Mobile Downloads

    #2
    change your mysql query, you are selecting all the messages there.
    Advertise your mobile site for FREE with AdTwirl

    Comment


      #3
      Thanks Bro
      ComputerForumz - Latest Tech News


      Mobbest.tk-Free Mobile Downloads

      Comment


        #4
        store sender, receiver and a message in database. and then make a sql query select msg from table where receiver = receiver

        follow diagrams of this link
        sigpic

        Comment

        Working...
        X