0
我有兩個表:抓鬥記錄ID期間提交併保存到另一臺
發票&發票零部件
我使用兩個表的原因是因爲我不想保存發票零部件陣列到Invoices表中的一個記錄中,我不想將它保存到Invoices表中的多個記錄中。
當我將數據提交到兩個表中時,如何將兩個表與ID連接在一起,如果我沒有ID?
$result = mysqli_query($mysqli, "INSERT INTO invoices(labelwarning, status, todaysdate, todaystime, todaysdatetime, avatar, firstname, lastname, mwaid, nextgenid, manager, manageremail, dispatcher, dispatcheremail, techemail, tag, serialnumber, currentequipment, company, address, city, state, zip, contactperson, contactnumber , currentdate, timearrived, timecompleted, login_id) VALUES('$labelwarning', '$status', '$todaysdate', '$todaystime', '$todaysdatetime', '$avatar', '$firstname', '$lastname', '$mwaid', '$nextgenid', '$manager', '$manageremail', '$dispatcher', '$dispatcheremail', '$techemail', '$tag', '$serialnumber', '$currentequipment', '$company', '$address', '$city', '$state', '$zip', '$contactperson', '$contactnumber ', '$currentdate', '$timearrived', '$loginId')");
$result2 = mysqli_query($mysqli, "INSERT INTO invoiceparts(partnumber, partdescription, partprice, partquantity, partdb, login_id) VALUES '$partnumberstring', '$partdescriptionstring', '$partpricestring', '$partquantitystring', '$partdbstring', '$loginId')");
你試過http://php.net/manual/en/mysqli.insert-id.php? –