php - how to stop dulicate entry and missing sequence while updating a database -


i taking max invoice no. table , incrementing 1 in , updating same table incremented value, problem multiple users performing operation, time misses sequence , time generating same sequence different jobs. can't make invoice no field unique other jobs 0. code like.

$res=mysql_query("select max(invoice_no) complaints_master"); $result=mysql_fetch_array($res); $code_id=$result[0]+1; // update invoice details in complaint master $usr="update complaints_master set invoice_no='$code_id', invoice_flag='1', invoice_date='$today', invoice_total_amt='$_post[final_total]' job_no='$_request[job_no]'"; 

you need set transaction level serializable ensure each max(invoice_no)+1 returns unique value client. not sure how while using php, here mysql doc: mysql set transaction syntax.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -