聊天应用代码

时间:2015-11-16 05:49:22

标签: javascript php jquery html mysql

我想打开一个特定人物的差异点击他的名字(给出)并且只想聊两个人...我无法理解如何在点击他/她的名字时获得差异。 ......如果有人能得到我的代码,Plzzz会帮助......“

<div class="chat-box">
    <div class="messages">
      <div class="name">
     //inside h5 tag want to display name using user id 
        <h5>Sagar</h5>
        </div>
      <div class="chat">
      <div class="msg1">
      <div class="self">

         <?php
        $name = $_SESSION['user_name']; 
         //Getting messages from database//!Not working
        $get="Select Sender,chat_info.User_id,Message,Time,DATE_FORMAT(Date_time,'%d-%m-%Y') Date_time 
              from chat_info 
              inner join chat_users 
              on chat_info.User_id=chat_users.User_id 
              where (chat_info.User_id=1 AND chat_info.User_id =5) OR (chat_info.User_id= 5 AND chat_info.User_id =1)  
              order by Time Desc;";
        $result=mysqli_query($con,$get);
        //var_dump($result);
      if($result == true)
      {
        if(mysqli_num_rows($result) > 0) 
    {
        // output data of each row
         $date=null;
        while($row = mysqli_fetch_assoc($result))
        {
            if($date!=$row['Date_time'])
            {
              $date=$row['Date_time'];
              echo "<h3 align='center'>".$date."</h3>";
            }
             echo  "<b style='color:blue;text-decoration:underline;'>".$row["Sender"]."</b></br>  ";
             echo  "<b>".$row["Message"]."</b>"."<br></br>";              
    }
}
    else
         { 
            echo "No messages";  
         }
       }
       else
       {
        echo "Error:".mysqli_error($con);
       }
      ?>
    </div>
    </div>
    <div class="msg2">
    <div class="friend">
     //Section of friends message
      </div>
    </div>
  </div>
   </div>
    <div class="online">
    <div class="online_frnds">
      <h2>Friends</h2>
//Here list of friends is there where i want to click on their name and open their specific div...
      <?php
         $name=$_SESSION['user_name'];
          $sql = "Select Firstname,Status from chat_users where Username !='$name'";
          $run=mysqli_query($con,$sql);
          if(mysqli_num_rows($run) > 0)
          {
             while($row=mysqli_fetch_assoc($run))
            {
              if($row["Status"] == 1)
             {

                echo "<div class='frnds_list'>";
                echo "<h5>";
                //echo "<b style='padding-left:12px;color:black;display:block'>";
                echo "<span><img src='online.png'height='10px' width='10px'>"."<a href='1.php?name=".$row['Firstname']."'>".$row['Firstname']."</a>"."</span>";
                echo "</h5>";
               // echo "</li>";
               // echo "</ul>";
             }
             else
             {
                echo "<div class='frnds_list'>";
                echo "<h5>";
                //echo "<b style='padding-left:12px;color:black;display:block'>";
                echo "<span><img src='offline.png' height='10px' width='10px'>"."<a href='1.php?name=".$row['Firstname']."'>".$row['Firstname']."</a>"."</span>";
                echo "</h5>";
               // echo "</li>";
                //echo "</ul>";

             }
           }
          }

       ?>
      </div>
    </div>
    </div>

0 个答案:

没有答案