我有一个表格,其中可以通过单击添加/删除按钮动态添加/删除新行。
当我尝试将新添加/删除的行保存回数据库时,我的问题就开始了。我设法使用 jQuery 的 Ajax 来保存数据,所以我没有使用 post var,而是“收集”每个输入上的所有数据。我设法获取所有这些数据并将它们发送到存储它们的 store.php。
我的问题是,如何用很少的查询保存我的更改,我的意思是,这是 store.php 发送到我的 mysql 服务器的输出:
UPDATE transport SET transporttype = "3" WHERE id = 1
UPDATE transport SET transporttype = "2" WHERE id = 6
UPDATE transport SET transporttype = "1" WHERE id = 7
UPDATE transport SET transportmandataire = "1" WHERE id = 1
UPDATE transport SET transportmandataire = "3" WHERE id = 6
UPDATE transport SET transportmandataire = "3" WHERE id = 7
UPDATE transport SET transportexpediteur = "1" WHERE id = 1
UPDATE transport SET transportexpediteur = "3" WHERE id = 6
UPDATE transport SET transportexpediteur = "3" WHERE id = 7
UPDATE transport SET transportdestinataire = "1" WHERE id = 1
UPDATE transport SET transportdestinataire = "2" WHERE id = 6
UPDATE transport SET transportdestinataire = "4" WHERE id = 7
UPDATE transport SET transporttransporteur = "5" WHERE id = 1
UPDATE transport SET transporttransporteur = "4" WHERE id = 6
UPDATE transport SET transporttransporteur = "3" WHERE id = 7
UPDATE transport SET transportbondetransportnumerodesuivi = "1563123" WHERE id = 1
UPDATE transport SET transportbondetransportnumerodesuivi = "23544" WHERE id = 6
UPDATE transport SET transportbondetransportnumerodesuivi = "23544" WHERE id = 7
UPDATE transport SET transportlivraisonprevisiondate = "1" WHERE id = 1
UPDATE transport SET transportlivraisonprevisiondate = "1" WHERE id = 6
UPDATE transport SET transportlivraisonprevisiondate = "1" WHERE id = 7
UPDATE transport SET transportlivraisonconstatdate = "test" WHERE id = 1
UPDATE transport SET transportlivraisonconstatdate = "test" WHERE id = 6
UPDATE transport SET transportlivraisonconstatdate = "test" WHERE id = 7
UPDATE transport SET transportlivraisonconstatheure = "test" WHERE id = 1
UPDATE transport SET transportlivraisonconstatheure = "test" WHERE id = 6
UPDATE transport SET transportlivraisonconstatheure = "test" WHERE id = 7
UPDATE transport SET transportlivraisonprevisiondate = "1" WHERE id = 1
UPDATE transport SET transportlivraisonprevisiondate = "1" WHERE id = 6
UPDATE transport SET transportlivraisonprevisiondate = "1" WHERE id = 7
UPDATE transport SET transportlivraisonprevisionheure = "1" WHERE id = 1
UPDATE transport SET transportlivraisonprevisionheure = "1" WHERE id = 6
UPDATE transport SET transportlivraisonprevisionheure = "1" WHERE id = 7
UPDATE transport SET transportetat = "6" WHERE id = 1
UPDATE transport SET transportetat = "1" WHERE id = 6
UPDATE transport SET transportetat = "6" WHERE id = 7
UPDATE transport SET transportimperatif = "09/17/2012" WHERE id = 1
UPDATE transport SET transportimperatif = "09/18/2012" WHERE id = 6
UPDATE transport SET transportimperatif = "09/09/2012" WHERE id = 7
UPDATE transport SET transportbondetransportmoyendetransmission = "2" WHERE id = 1
UPDATE transport SET transportbondetransportmoyendetransmission = "2" WHERE id = 6
UPDATE transport SET transportbondetransportmoyendetransmission = "1" WHERE id = 7
UPDATE transport SET transportbondetransportassurance = "86" WHERE id = 1
UPDATE transport SET transportbondetransportassurance = "86" WHERE id = 6
UPDATE transport SET transportbondetransportassurance = "86" WHERE id = 7
UPDATE transport SET transportobservation = "Aucune observation disponible." WHERE id = 1
UPDATE transport SET transportobservation = "Aucune observation disponible." WHERE id = 6
UPDATE transport SET transportobservation = "Aucune observation disponible." WHERE id = 7
UPDATE transport SET transportreclamationmotif = "3" WHERE id = 1
UPDATE transport SET transportreclamationmotif = "4" WHERE id = 6
UPDATE transport SET transportreclamationmotif = "1" WHERE id = 7
UPDATE transport SET transportreclamationnumerosuivis = "B87GT9" WHERE id = 1
UPDATE transport SET transportreclamationnumerosuivis = "656786" WHERE id = 6
UPDATE transport SET transportreclamationnumerosuivis = "C89GF8" WHERE id = 7
UPDATE transport SET transportreclamationdate = "09/17/2012" WHERE id = 1
UPDATE transport SET transportreclamationdate = "09/10/2012" WHERE id = 6
UPDATE transport SET transportreclamationdate = "09/24/2012" WHERE id = 7
UPDATE transport SET transportreclameetat = "2" WHERE id = 1
UPDATE transport SET transportreclameetat = "1" WHERE id = 6
UPDATE transport SET transportreclameetat = "1" WHERE id = 7
UPDATE transport SET transportreclamationrelancedate = "09/19/2012" WHERE id = 1
UPDATE transport SET transportreclamationrelancedate = "09/04/2012" WHERE id = 6
UPDATE transport SET transportreclamationrelancedate = "09/17/2012" WHERE id = 7
UPDATE transport SET transportreclamationrelancemoyen = "1" WHERE id = 1
UPDATE transport SET transportreclamationrelancemoyen = "1" WHERE id = 6
UPDATE transport SET transportreclamationrelancemoyen = "1" WHERE id = 7
UPDATE transport SET transportindemnisationdate = "09/06/2012" WHERE id = 1
UPDATE transport SET transportindemnisationdate = "09/19/2012" WHERE id = 6
UPDATE transport SET transportindemnisationdate = "09/11/2012" WHERE id = 7
UPDATE transport SET transportindemnisationmontant = "600" WHERE id = 1
UPDATE transport SET transportindemnisationmontant = "600 €" WHERE id = 6
UPDATE transport SET transportindemnisationmontant = "600" WHERE id = 7
UPDATE transport SET transportindemnisationmoyen = "1" WHERE id = 1
UPDATE transport SET transportindemnisationmoyen = "1" WHERE id = 6
UPDATE transport SET transportindemnisationmoyen = "1" WHERE id = 7
UPDATE transport SET transportreclamationobservation = "Non pas d'observation" WHERE id = 1
UPDATE transport SET transportreclamationobservation = "non plus" WHERE id = 6
UPDATE transport SET transportreclamationobservation = "encore moins" WHERE id = 7
不用告诉你这太慢了,就像 5 秒来一个一个地存储所有数据。