How to insert multiple datas with mysqli OO

0 Thierno BAH · April 17, 2015
Hi everyone

I'm trying with the following code to insert multiple datas at once:

$db->query("UPDATE users SET solde = solde - '$aDeduire' WHERE telephone = '$msisdn'");// works
$db->query("UPDATE users SET solde = solde + '$montant' WHERE telephone = '$numaPayer'"); // works
$db->query("UPDATE systems SET solde = solde + '$fraisTransaction' WHERE nom = 'SYSTEM'");// works
$db->query("INSERT INTO transactions (day, description, expediteur, destinataire, debit, credit, numserie ) 
VALUES (NOW(), '$textExp', '$msisdn',null ,'$montant',null , '$numSerie')"); // not working
$db->query("INSERT INTO transactions (day, description, expediteur, destinataire, debit, credit, numserie )
VALUES (NOW(), '$textDes't, null, '$numaPayer', null,'$montant', '$numSerie')"); // not working
$db->query("INSERT INTO transactions (day, description, expediteur, destinataire, debit, credit, numserie )
VALUES (NOW(), '$textSyst', null,'SYSTEM', null, '$montant', '$numSerie')"); //not working


Can anyone help

Post a Reply

Replies

Oldest  Newest  Rating
0 Thierno BAH · April 18, 2015
hello
here is how I solved it.


$db->query("INSERT INTO transactions (day, expediteur, destinataire, debit, credit, description, numserie) 
VALUES (NOW(), '$msisdn','' ,'$montant', 0, '$textExp', '$numSerie'), 
(NOW(), '', '$numaPayer', 0,'$montant', '$textDest', '$numSerie'),
(NOW(), '$msisdn','', '$fraisTransaction', 0, '$textFrais', '$numSerie'), 
(NOW(), '','SYSTEM', 0, '$fraisTransaction', '$textSyst', '$numSerie')");
  • 1

PHP

107,039 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators