1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| $quantite = $_POST['qte'];
$total = $quantite * $membre10->prix;
$codes = $db->prepare('SELECT * FROM codes WHERE type = ? AND utilisation = ?');
$codes->bindValue(1,$membre10->id_code, PDO::PARAM_INT);
$codes->bindValue(2,'0', PDO::PARAM_INT);
$codes->execute();
while($codeach=$codes->fetch(PDO::FETCH_OBJ)) {
$coderip = $codeach->id_code;
for($i=0; $i<$quantite; $i++) {
$codes1 = $db->prepare('SELECT * FROM codes WHERE id_code = ?');
$codes1->bindValue(1,$coderip, PDO::PARAM_INT);
$codes1->execute();
$codeach32=$codes1->fetch(PDO::FETCH_OBJ);
$coderip1[$i] = $codeach32->code;
$addClient1 = $db->prepare("INSERT INTO achat_codes (id_membre,timetemps,id_code,codes,montant,nbr_code) VALUES (:id_membre,:timetemps,:id_code,:codes,:montant,:nbr_code)");
$addClient1->bindParam('id_membre',$_SESSION['id_membre'], PDO::PARAM_INT);
$addClient1->bindParam('timetemps',time(), PDO::PARAM_INT);
$addClient1->bindParam('id_code',$_POST['id_prod'], PDO::PARAM_INT);
$addClient1->bindParam('codes',$codes1, PDO::PARAM_INT);
$addClient1->bindParam('montant',$total, PDO::PARAM_INT);
$addClient1->bindParam('nbr_code',$_POST['qte'], PDO::PARAM_INT);
//$addClient1->execute();
$nouvdemande1 = $db->prepare('UPDATE codes SET utilisation=:utilisation where code=:id');
$nouvdemande1->bindValue('utilisation','1', PDO::PARAM_INT);
$nouvdemande1->bindValue('id',$codes1, PDO::PARAM_INT);
//$nouvdemande1->execute();
$form_data['posted'] = $coderip1; // <----------- ce résultat m'affiche deux fois le même code
}
} |
Partager