Reputation: 1349
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?
Upvotes: 1
Views: 1017
Reputation: 11
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.)
Upvotes: 0
Reputation: 23244
A table, something like:
id, fromip, toip, country
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
Upvotes: 1