I want to execute this function everyday. I am using Xampp for development and testing with CodeIgniter as a framework which uses php and mysql.
this code works fine to populate the database table with the current day but i want to do it automatically with an event not a trigger
people told me to use CRON but i don't know how to create the files and where to put them since i am using windows for hosting
function create_users_records(){
//get the user's IDs and number
$this->db->select('id');
$query = $this->db->get('users');
$number_of_employees = $query->num_rows();
echo "number of employees is: ".$number_of_employees."<br>";
for ($i = 0; $i < $number_of_employees; $i++) {
$row = $query->row($i);
echo $row->id ."<br>";
//date and time now
$time = time();
//date format
$datestring = "%Y-%m-%d";
$data = array(
'Attendence_date_daily' => mdate($datestring, $time),
'Check_in_time' => null,
'Check_out_time' => null,
'Attendence_status' => null,
'Employee_comment' =>null,
'Deducted_today' => 0,
'user_id' => $row->id
);
$this->db->insert('daily_attendence_record', $data);
}
}
I am creating an attendance system and I am required to create the daily records for all users at midnight so they can check in/out before that time and to record their vacations and absences.