Insert without duplicates errors

When inserting data into the table, the code stops working because there are similar data to the data that will be entered
How can I implementation of code insertion on the empty data and ignore inserted before …
and how ignore the message appears repetition
note: I placed restrictions to prevent duplicate data

How to avoid stop working the code , and show another error message

$arr=[i];
[selected][$arr]={EmployeeNo};
[i]++;
/**/
$vDeducted_StartDate = [vDeducted_StartDate];
$vDeducted_EndDate = [vDeducted_EndDate];

if(count([selected]) > 0)
{
$to_copy = implode(’,’,[selected]); //"(".implode(’,’,[selected]).")"; Deducted_StartDate, Deducted_EndDate = curdate(), last_day(curdate()),
//$sql = “INSERT INTO Food_BonDeduction (EmployeeNo, Deducted, Deducted_StartDate, Deducted_EndDate, Accommodat_Emp_IDF) SELECT EmployeeNo, ‘نعم’,curdate(), last_day(curdate()), Accommodat_Emp_ID FROM view_newaccommodates WHERE EmployeeNo =’$to_copy’”;
$sql = “INSERT INTO Food_BonDeduction (EmployeeNo, Deducted, Deducted_StartDate, Deducted_EndDate, Accommodat_Emp_IDF) SELECT EmployeeNo, ‘نعم’, ‘$vDeducted_StartDate’, ‘$vDeducted_EndDate’, Accommodat_Emp_ID FROM emp_accommodate WHERE EmployeeNo =’$to_copy’”;
sc_exec_sql($sql);
[selected] = array();
}
image

Application->Messages ?

Hi,
you use in your clause Insert IGNORE like this:
INSERT IGNORE INTO

1 Like

Thanks for your response
I will try tomorrow

“You have no idea how much your help has meant. and I can never thank you enough.”

Is there a way in make a loop to insert dates from start date to end date one time