this is my program, I have tried but it inserts with duplicate data
please help me
$minute = date("i:s");
$datesql = date('Y-m-d H:i:s');
if($minute=="10:00"){
$qrecord = mysqli_query($conn220,
"INSERT INTO `history_rpm_mesin`(`id`, `nomesin`, `shift`, `nama_op`, `flv`, `rpm`, `std`, `time_stamp`, `dept`)
VALUES ('','$nomesin','$sh_op','$namaop','$flv','$value','$rpm_op','$datesql','BUMBU')");
}
2
Answers
Yes it is possible. But you will need to look at something like
cron
to run your script at the scheduled time.This is the cron expression for running your script every 10 minutes:
For this to work though, your script needs to be callable via the PHP CLI. That means it will not be executing in the same context as a web request.
Depending on what the rest of the code looks like, you may need to make some changes in your assumptions about where the data comes from.
At the very least, when using cron in this way, the code you’ve shown could be simplified to:
Use cronjob would be a better choice but if you want to run script inside a page, consider that you need to check if last 10 min is already exist or not. So your code will be something like this: