Jump to content

Avoid inserting records with the same id_incr value


jeff5656

Recommended Posts

Before inserting a record into a table, I want to check to make sure a record with the same "id_incr" does not exist.

The following code "tries" to do that, but it doesn't work.

 

$patient_name = $_POST['patient_name'];
$mrn = $_POST['mrn'];
$fellow = $_POST['fellow'];
$rcf_date = $_POST['rcf_date'];
$consult_reason = $_POST['consult_reason'];
$impression = $_POST['impression'];
$recs = $_POST['recs'];
$followup_reason = $_POST['followup_reason'];
$followup_date = $_POST['followup_date'];
$id_incr = $_POST['id_incr'];


$check_dup = "SELECT id_incr FROM followup";
mysql_query ($check_dup) or die (mysql_error());

*/ do I put an IF statement here now?

No I want to make sure that the record with id_incr is not inserted in the table twice (like a user who submits the same patient twice).  If I set it to auto-increment, then that number will be different, but the record will indeed be a duplicate..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.