douzhang5121 2017-07-14 11:00
浏览 57

mysql不会同时插入5到10个用户提交的同一个php表单的所有数据

I am using php form to submit student fee.if single user submit that form, everything is working fine and data saving in MySQL database.but if i use to submit that form from 5-10 different system at same time, then MySQL inserting two or three user's data only. I am using trigger for invoice_id :

CREATE TRIGGER `test_trig` BEFORE INSERT ON `student_fee_transaction_details`
 FOR EACH ROW BEGIN
    SET NEW.inv_no=(SELECT CONCAT(NEW.school_id,'-', SUBSTRING_INDEX( inv_no,  '-', -1 ) +1 ) AS inv_number_new
FROM student_fee_transaction_details
WHERE id IN (SELECT MAX( id ) FROM student_fee_transaction_details WHERE school_id = NEW.school_id
));
END

here is my php code to insert

insert into student_fee_transaction_details (id,fine_amount,interest_amount,handling_charges,
institute_id,school_id,student_id,class_id,section_id,admission_no,fees_amount,payment_date,
payment_mode,paid_amount,inv_date,inv_ref_no,inv_no,inv_status,session,payment_bank,payment_type,
cheque_dd_no,payment_chanel,fee_due_date,cheque_dd_date,remarks,deposit_bank_id)
values('','$fine_amt','$interest_amt','$hand_charge','$ins_id','$sch_id','$stu_id','$cls_id',
'$sec_id','$adm_no','$total_fee_paid_amt','$pay_dt','Manual','$total_paid_amt','$inv_dt',
'$ref_no','1898776','Invoiced','$session','$bank_nm','$pay_type','$dd_chq_no','web',
'$fee_due_date','$dd_cheq_dt','$swipe_remarks','$deposit_bank')";
 $result_inv_master = $con->query($qry_inv_master); 
  • 写回答

1条回答 默认 最新

  • doujiao3346 2017-07-14 13:29
    关注

    Just make your id column as Auto Incremented and don't pass id value as '' in your query. Like this

    insert into student_fee_transaction_details (fine_amount,interest_amount,handling_charges,
    institute_id,school_id,student_id,class_id,section_id,admission_no,fees_amount,payment_date,
    payment_mode,paid_amount,inv_date,inv_ref_no,inv_no,inv_status,session,payment_bank,payment_type,
    cheque_dd_no,payment_chanel,fee_due_date,cheque_dd_date,remarks,deposit_bank_id)
    values('$fine_amt','$interest_amt','$hand_charge','$ins_id','$sch_id','$stu_id','$cls_id',
    '$sec_id','$adm_no','$total_fee_paid_amt','$pay_dt','Manual','$total_paid_amt','$inv_dt',
    '$ref_no','1898776','Invoiced','$session','$bank_nm','$pay_type','$dd_chq_no','web',
    '$fee_due_date','$dd_cheq_dt','$swipe_remarks','$deposit_bank')";
     $result_inv_master = $con->query($qry_inv_master); 
    

    Do the changes then this issue will not came again.

    评论

报告相同问题?

悬赏问题

  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法