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?

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.