Jump to content

Recommended Posts

I suppose you are logging a unix timestamp for each chat entry.  You would then need to define a timestamp when a user logs in, and not display any chat messages that occurred before that timestamp.

//user logs in
if(isset($_SESSION['timestamp'])) {
$time = $_SESSION['timestamp'];
}
else {
$time = $_SESSION['timestamp'] = time();
}
$sql = "SELECT * FROM `chat` WHERE `room` = '$room_id' AND `time` > '$time'";

 

Or, something along those lines.

Hi all,

 

I was able to compare the last time a new message was posted against the time a user login. My question now is, If the last time a new message was posted is less than the time the user log in, how will my sql query look like so that it doesn't display the old message

If($newmsgtime < userlogintime){
$sql=mysql_query(????)

 

thanks for your time

$sql = "SELECT * FROM `chat` WHERE `room` = '$room_id' AND `time` > '$time'";

 

Since I see no code on this thread, I cannot give you a clear answer.

1. We don't know what format $newmsgtime is.

2. We don't know what format userlogintime CONSTANT is.

3. We don't know what the time column in your database is.

4. We don't know what the name of your time database column is.

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.