Im i have a php form to enter data into a mysql database, my question is how do i handle duplicate records for example if an ID number already exsists how do i check if exsists
eigther check before inserting or do and update.
check
"SELECT COUNT(*) FROM loan WHERE loan_id = '" . $values['load_id'] . "'"
update
"INSERT INTO loan (loan_id, some_field) VALUES ('". $values['loan_id'] ."', '". $values['some_field'] ."') ON DUPLICATE KEY UPDATE some_field = VALUES(some_field)";