Advertisement
DigitMagazine

Creating a database for the web page visitor counter

Feb 25th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. Creating a database for the web page visitor counter:
  2.  
  3. The first thing we’re going to do is create a database in MySQL and call it “visitors”. Using “phpMyAdmin”, open up this “visitors” database ” and run the following SQL to create the tables in your database.
  4.  
  5. CREATE TABLE IF NOT EXISTS `visit` (
  6. `id` int(12) NOT NULL AUTO_INCREMENT,
  7. `ip_address` varchar(12) COLLATE utf8_unicode_ci NOT NULL,
  8. `visit_count` varchar(12) COLLATE utf8_unicode_ci NOT NULL,
  9. PRIMARY KEY (`id`),
  10. UNIQUE KEY `ip_address` (`ip_address`)
  11. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=6 ;
  12. The above SQL code will create a table named “visit” and include three columns in it. The first column is for “ID” with “Auto_Increment” property. The second column is for “ip_address”, which we’ll use to store the IP addresses of each site user. And the third column is for “visit_count” – this is for unique visitors to your website who visit more than once. Each time this user stops by, the value in this column is incremented by 1.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement