DEV Community

Elijah Emmanuel
Elijah Emmanuel

Posted on

How can i create a CRON operation to add numbers based on timed events in my database.

please, how can i create a cron operation that will add numbers to the existing numbers based on my present database value when the next event is to be executed?

here is the code below:

<?php
$sql="CREATE EVENT test_event_05
ON SCHEDULE EVERY 1 MINUTE
STARTS CURRENT_TIMESTAMP
ENDS CURRENT_TIMESTAMP + INTERVAL 1 HOUR
DO
   INSERT INTO messages(email,income,created_at)
#i would like to add 20 at the next execution so that the income which is 30 would change to 60;

   VALUES('elijahemmanuel05',30,NOW());";

  if($conn->query($sql) == "true"){
    echo 'created';
  }else {
    die("not created".$conn->error);
  }
?>
Enter fullscreen mode Exit fullscreen mode

please help me guys, its urgent

Top comments (0)