Friends I have created a mysql table to get the page visits for my website. My table is like this
statistics_table(stat_id,visited_page,visit_count)
I agree with the answer above, but I recommend that you use MySQL events. See CREATE EVENT in the MySQL manual for more details.
In summary, your event should be:
CREATE EVENT myevent
ON SCHEDULE Every Day
DO
INSERT INTO Table_name(stat_id,visited_page,visit_count)
SELECT stat_id,visited,visit_count_page FROM Exist_Tablename WHERE date_field =
DATE_SUB(CURDATE(), INTERVAL 1 DAY);
DELETE FROM Exist_Tablename
WHERE date_field = DATE_SUB(CURDATE(), INTERVAL 1 DAY);
You can use the following query statement to insert datas to another table,
INSERT INTO Table_name(stat_id,visited_page,visit_count)
SELECT stat_id,visited,visit_count_page FROM Exist_Tablename WHERE <condition>;
DELETE FROM Exist_Tablename
WHERE <condition>;
Like this you can try,
This may helps you.