Jump to content

Chat Messages


balkan7

Recommended Posts

Hi,

Does someone can help me with this code to get the results that the messages is displayed one time and do not duplicate it, if it be shown whether it is possible to change the status, for example, if status of message in datebase is 1 after it is shown to change the status of the 2?

 

ajax.js

function display_msg(){
doc_id("new_msg").innerHTML="<br />";
makeHttpRequest(siteurl+"/ajax.php?a=new_msg",function(response){doc_id("new_msg").innerHTML+=response;},false);

  setInterval("display_msg()", 10000);
}

 

php

<?php
$result = mysql_query("SELECT * FROM ".DB_CHAT." WHERE status='1' ORDER BY date LIMIT 0,1");
while($data = mysql_fetch_array($result)){
  $user = $data['user'];
          $msg = $data['msg'];
          echo $user." - ".$msg;
}
?>

Link to comment
Share on other sites

Here is explame, when user send msg status in datebase is 0, when i confirm msg for show it then status is 1, and ajax check in datebase messages with status 1, if find show it but if we havent new messages ajax do not show nothing ...

like:

 

msg 10

msg 9

msg 8

 

i hope undestand me ...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.