Reputation: 159
I have a table full of page visits, each of the page visits have a unique ID, A visit ID and a Page Time.
By Database structure is below:
CREATE TABLE IF NOT EXISTS `pages` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`client_id` int(11) NOT NULL,
`url` text NOT NULL,
`visit_id` varchar(100) NOT NULL,
`url1` varchar(255) NOT NULL,
`page_time` time NOT NULL,
PRIMARY KEY (`id`)
)
What I am trying to work out is, is there a way to subtract one page time from another to identify how long somebody was on the previous page.
So I have a simple query which groups the results
SELECT * FROM pages group by visit_id
what i am trying to work out, is, is there a way to subtract one page time variable from another in order of their group?
Any ideas would be appreciated
Upvotes: 1
Views: 230
Reputation: 4565
Use session to store the current time when user visits a page. Then when user goes to another page, subtract last loading time from current time and you'll get how long the user was on the last page.
Upvotes: 1