简体   繁体   English

相互减去PHP变量

[英]Subtract PHP variables from one another

I have a table full of page visits, each of the page visits have a unique ID, A visit ID and a Page Time. 我有一个充满页面访问量的表,每个页面访问都有一个唯一的ID,一个访问ID和一个页面访问时间。

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 任何想法,将不胜感激

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. 然后,当用户转到另一页面时,从当前时间中减去上次加载时间,您将获得用户在最后一页上停留的时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM