I try to use on duplicate key update in my query but it still duplicate some value.
My query is like this:
$insert=mysqli_query($conn,"insert into tbl_staffdistribution(db_user,db_name,db_responsible,db_date)values('$user','$name','$responsible','$formatteddatetimein') on duplicate key update db_user='$user',db_name='$name',db_responsible='$responsible',db_date='$formatteddatetimein'")or die(mysqli_error($conn));
In order to do this. you should be having a
unique key within your table so that you can use it for
on duplicate key update as such. The unique key can be your primary or some other field from your table. You can do something like this within your query:
ON DUPLICATE KEY UPDATE someID = VALUES(someID)
A clear cut explanation from MySQL.