作者powyo (抛又)
看板PHP
标题[请益] 计算点击数
时间Fri Oct 17 15:02:41 2014
我想做一个分析 网站上有不同的商品连结
想做统计每个使用者 点击各品牌的次数
目前想法是点一次就insert进资料库 品牌,使用者名,时间
这样要如何计算比较方便呢
想作成表格如下
使用者 品牌1 品牌2 品牌3
powyo 2 50 12
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 210.62.185.25
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/PHP/M.1413529365.A.B06.html
1F:推 meteorsok: user_id, product_id, created_at 10/17 15:20
2F:→ meteorsok: sorry...brand_id = =... 10/17 15:21
3F:推 ckmarkhsu: 可以推直接用GA 做就好吗XD 不要自干 10/17 15:34
4F:→ powyo: 什麽是GA? 10/17 17:07
5F:→ powyo: 硬干是可以做出来 但太麻烦了 不知有没有好方法= = 10/17 17:08
6F:→ powyo: 每个使用者的品牌都要count 想到就头痛.. 10/17 17:09
7F:→ tper8042: Google Analytics? 10/17 17:11
8F:推 meteorsok: 一点也不麻烦吧 10/17 17:36
9F:→ meteorsok: select count(user_id), tbl.* from tbl 10/17 17:37
10F:→ meteorsok: group by brand_id 10/17 17:37
11F:→ powyo: 这样可以算出每个品牌被使用者点了多少次吗? 10/17 17:56
12F:→ meteorsok: 忘记要先group user_id => group by user_id, brand_id 10/17 17:56
13F:→ powyo: 你这样说我就懂了 不过我已经下班 只好下礼拜一在试试看 10/17 17:58
14F:→ powyo: 感恩 10/17 17:58
15F:→ powyo: 这样出来的结果 假设有8个品牌 就会有8个值吗? 10/17 18:01
16F:推 meteorsok: userA brandA countA , userB brandB countB 10/17 20:27
17F:→ meteorsok: userA brandB countX blahblah 10/17 20:28
19F:→ cf1064: 每次点击就去资料库搜使用者and产品,当存在时就用update 10/17 23:27
20F:→ cf1064: +1,不存在时就insert 使用者、产品、数量=1 10/17 23:28
21F:推 duck10704: Google Analytics event tracking +1 10/19 02:09