I have a page which analyzes a MySQL log table in order to display the progression of a single session. It works very well and has provided some very valuable information.
I am trying to add links at the bottom of this page to view these statistics for the next and previous sessions (based on the time the session started). I tried this query to get the ID of the next session:
SELECT session_id
FROM page_views
WHERE time > $start_time
AND session_id <> '$session_id'
ORDER BY time
LIMIT 1
(where $start_time is the time that the current session started, and $session_id is the id of the current session)
It works for most cases, but I run into a problem when two different sessions overlap, because the query doesn't just return results from the _first_ page view recorded for a session (so sometimes it comes up with the same session as both the next and the previous sessions). My page_views table contains info about the request, the time the page was served, and the session id.
Can anyone think of a way to do this, without adding a field to the table to indicate the start of a session?
Any advice is greatly appreciated.
-Keegan
I am trying to add links at the bottom of this page to view these statistics for the next and previous sessions (based on the time the session started). I tried this query to get the ID of the next session:
SELECT session_id
FROM page_views
WHERE time > $start_time
AND session_id <> '$session_id'
ORDER BY time
LIMIT 1
(where $start_time is the time that the current session started, and $session_id is the id of the current session)
It works for most cases, but I run into a problem when two different sessions overlap, because the query doesn't just return results from the _first_ page view recorded for a session (so sometimes it comes up with the same session as both the next and the previous sessions). My page_views table contains info about the request, the time the page was served, and the session id.
Can anyone think of a way to do this, without adding a field to the table to indicate the start of a session?
Any advice is greatly appreciated.
-Keegan