Jump to content

Send next ID number as workorder number in email


smcan

Recommended Posts

I have a very basic form (last name, first name, building, extension, email, request). Currently a user can fill out the form and submit and it will send an email as a work order for plant operations personnel and send a copy to the submitter. I want to use the ID number of the record as the work order number for user and operations personnel to track the issue. How can I get the ID number to add to the copy of the email going to the submitter? It seems it would have to connect to the database, get the next ID number, store it as a variable then do the rest of the script.

 

Any help is appreciated.

You need to store the record first, then get the id that was set when the record was stored.  For mysql, you want to use mysql_insert_id()/mysqli_insert_id();

 

If you try to get the next number first, you setup a race condition where multiple threads could go at the same time and get the same number as the next insert id, but only one of them would actually use that number when the records are inserted.

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.