0

I have a table named tbl_cartag and in table have temp field after user enter data must be erased after 24 hours.

I want this field to be cleared every 24 hours Information.

This is my query

DELETE cartag FROM tbl_cartag WHERE tcartagid=( $_GET['tcartagid'] )

I read similar questions , but I did not help

Remove a row from the database after 24 hours in php

Deleting Data each 24 hours in Database with PHP and MYSQLi

Community
  • 1
  • 1
davood Jafari
  • 64
  • 1
  • 10

3 Answers3

0

If you're running on Linux/Unix (including Mac OSX), create a cron job.

if you are using windows then use event scheduler

it will work

Kamlesh Gupta
  • 505
  • 3
  • 17
0

I think this option is better:

DELETE 
FROM YOUR-TABLE
WHERE
YOUR-DATE-COLUMN < DATE_SUB(NOW(), INTERVAL 2 DAY);
Noman
  • 1,459
  • 2
  • 18
  • 38
0

If you want to truncate/erase everything from temp table Then you can run the above query

DELETE cartag FROM tbl_cartag WHERE tcartagid=( $_GET['tcartagid'] )

also you have to create a cron job for this query.

Or if you want to erase 24 hours data from temp table then you have to add Data time query as mentioned by Syed noman

YOUR-DATE-COLUMN < DATE_SUB(NOW(), INTERVAL 2 DAY)
Manish
  • 3,443
  • 1
  • 21
  • 24