如何使用PHP/MYSQL获取关键词统计
我正在寻找一种显示标签/关键字的排名/统计信息的方法。我尝试过但没有成功。我非常了解 PHP,但我对如何使用 PHP/MYSQL 获取关键字的统计信息感到困惑。
像这样: http://bit.ly/gHLXXo (又名 http://www.torrentpond.com/stats/keywords)。
请解决我的问题。
编辑:我只是创建一个关键字表..带有(ID,关键字,时间,视图)列并使用一些查询来获取结果..但没有运气..我不知道如何管理它..我需要吗每天添加 30 列,还是需要使用序列化将数据库存储为数组?有什么解决方案请给我...
EDIT2:我不需要图表或图表;我只需要关键字趋势。
I am Looking for a way to display ranking/statistics of Tag/Keywords. I tried but no success. I know PHP very well but I am confused about how to get statistics of a keyword using PHP/MYSQL.
Like this: http://bit.ly/gHLXXo (aka http://www.torrentpond.com/stats/keywords).
Please Solve my Problem.
EDIT: I just create a keywords table.. with (ID, Keywords, time, view) column and use some query to get result.. but no luck.. I don't know how to manage it.. Do I need to add 30 columns for each day or do I need to use serialize to store database as array? Is there any solution please give me ...
EDIT2: I don't need a chart or graph for this; I just need the keyword trends.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要这样的 sql 查询:
其中“行”= 该关键字的计数,“关键字 id”= 关键字 id 或名称。
这将返回前 30 个关键字以及该关键字出现的次数。
You need sql query like this:
Where "Rows" = count of this keyword and "keyword-id" = keyword id or name.
This return you top 30 keywords with the number of times the keyword appears.
您的第一步应该考虑需要哪些数据来生成统计数据。
您需要跟踪各个关键字(或关键字组)。然后,每次使用其中一个关键字时,您都将在统计表中插入一条记录,该记录标识该关键字以及使用该关键字的日期/时间。当搜索关键字是新的时,您将在关键字列表中创建一个新的关键字条目,并在“关键字的使用”表中创建一个条目。
然后,您的聚合处理需要计算每个关键字在相关期间的使用频率。你可以每天这样做;您不会追溯添加新记录。鉴于随着时间推移存储的聚合数据,您可以计算位置(排名)和位置变化。如果需要的话,您可以在几天、几周、几个月内进行汇总。聚合数据将与操作数据存储在单独的表中。一旦基本时间单位(可能是一天,可能是一个小时)过去,您可以考虑是否删除原始数据 - 在完成第一步聚合之后。
Your first step should to consider what data is needed to allow the statistics to be generated.
You will need to keep track of the individual keywords (or sets of keywords). Then, for each time one of the keywords is used, you'll insert a record into a statistical table which identifies the keyword and the date/time when it was used. When the search keyword is new, you create a new keyword entry in the list of keywords, as well as an entry in the 'use of keywords' table.
Your aggregate processing then needs to compute how often each keyword was used in the relevant period. You can do this daily; you won't be retrospectively adding new records. Given the aggregated data stored over time, you can compute positions (rankings) and changes in position. You can aggregate over days, weeks, months if need so be. The aggregate data will be stored in separate tables from the operational data. Once the basic unit of time (probably the day, maybe an hour) is past, you can consider whether to remove the original raw data - after you've done the first step aggregations.