Wednesday, 2 December 2015

46_visitor_ip_into_database

SQL TAB IN PHPMYADMIN


1) let’s demonstrate the query concept in phpmyadmin by clicking on SQL TAB from phpmyadmin.




2) select specific column from table.




Click on GO.


3) SELECT * FROM `tbl_admin` WHERE 1 , will return all the record in phpmyadmin.


4) select data with where condition.
SELECT * FROM `tbl_admin` WHERE 'admin_id'=1


5) Update data
UPDATE 'tbl_admin' SET 'admin_uname' = 'HARSHU' WHERE 'admin_id'= 1


DATABASE HIT COUNT


Create one home.php page and one table in your database (tbl_hit_count)



And add one default value as a ZERO “0”. Also create one another table …


Create one page named connect_database.php page and write the code as we have already learn in previous post.


Here in this example we are going to add the user ip address into database at the first time user visit our site and increment user visit as well … Later if the user visit our again means to check the user ip address already exists in our database then we will not increment our visitor count into our database table.




Here we have created one simple function update_hit_visit(),whenever we refresh our page then in our database table named “tbl_hit_count” value will be updated. So till now we have learn how to increment the table value now let’s take the user IP address and store into our database if it is not exists in to the record.




When you run the above code then our IP address store into the table tbl_his_ip_add. Later we will only insert if the IP ADDRESS NOT EXISTS.




Before running this page first remove all the record from tbl_his_ip_add table as well as make zero “0” in our table tbl_hit_count, now run the page and check out the database table record.




No comments:

Post a Comment