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
https://forums.phpfreaks.com/topic/158138-chat-messages/
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
https://forums.phpfreaks.com/topic/158138-chat-messages/#findComment-834705
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.