Jump to content

PHP/mysql output query


depojones

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.

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.