I have a service that shows a specific button when a session is "ready", i.e. 15 minutes beforehand and through the session.
I am doing this by pulling up all recently requested sessions, analyzing their timestamps, and then pulling out a specific ID if that session is upcoming. Here is the code:
$session_check_query = "SELECT * FROM requested_sessions WHERE username_t = '{$_SESSION['username']}'";
$session_check_process = mysql_query($session_check_query);
date_default_timezone_set($_SESSION['timezone']);
$current_time = time();
while ($sessions = mysql_fetch_array($session_check_process)) {
if ($sessions['time_from_t'] - $current_time <= 900 && $current_time - $sessions['time_from_t'] > 0 && $sessions['accepted'] == 1) {
$session_id = $sessions['id'];
}
}
The problem is that when I echo $session_id in the loop it will output 1, 2, 3, 4. This means that it feels that all of my sessions in the database meet this criteria when they don't only one does.
Is there a problem with this code? time_from_t is in UNIX format.