在 PHP 和 PHP 中跟踪用户的国家/地区MySQL
我正在创建一个 URL 缩短网站。我想允许用户查看链接的统计信息。我计划做国家统计。我想我应该使用一个类似于GeoIP for PHP的库来获取国家,但是,怎么可能是MySQL。我的弱点是 MySQL 表的设计。您能给我推荐一种表格格式吗?
I'm creating a URL Shortening website. I want to allow users to view the stats for the links. I planned to do Country stats. I think I should use a library similar to GeoIP for PHP to get the country, but, how can be the MySQL. My weakness is the design of the MySQL tables. Can you recommend me a table format, please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一个表格,类似于:
使用 IP 范围的数字格式,您将用它来查询国家/地区。
还:
如何存储和搜索 IP 地址
A table, something like:
Use the number format for the ip ranges which you'll use to query for the country.
Also:
How to store and search for an IP Address
我要做的是,对于每个视图,我都会获取正在查看的人的 ip、纬度和经度,或者您想要用于跟踪的任何内容。也许有
id、ip、lat、long、url
。 id 可以自动递增,并且 ip、纬度和经度可以结合起来为您提供准确的结果。只需从表中选择 URL 与所需 URL 相同的行即可。 (如果您想显示所有用户链接的统计信息,您还可以有一个“用户”列。)What I would do is for each view, I would take the person who is viewing's ip, lat&long, or whatever you want to use for tracking. Perhaps have either
id, ip, lat, long, url
. The id could be autoincremented, and the ip, latitude, and longitude might combine to give you accurate results. Just select the rows from the table where the URL is equal to the one wanted, and you're set. (You could also have a 'user' column, if you want to show stats for all of the user's links.)它最适合我
http://www.ipinfodb.com/ip_location_api.php
It works best for me
http://www.ipinfodb.com/ip_location_api.php