PHP-Mysql boucle FOR

volumeni -  
 volumeni -
Bonjour,
j'ai un $ingredient1, un $ingredient2 et un $ingredient3
chacun a respectivement une $quantite1 $quantite2 et $quantite3

j'aimerais faire

mysql_query("UPDATE `inventaire` SET `quantite` = '".$quantite1."' WHERE `nom_objet` ='".$ingredient1."';")or die ("erreur update quantites ingreds :".mysql_error());


mais avec un FOR parce que j'ai un peu + que 3 ingrédients

comment faire ? merci
Configuration: Windows Vista / Internet Explorer 7.0

1 réponse

  1. volumeni
     
    en fait je viens de trouver
    il suffit de remplacer les variables sous la forme
    $ingredient[1] et non pas $ingredient1

    apres on peut écrire

    for($i=0; $i<3 ;$i++){
            mysql_query("UPDATE `handkrafting_inventaire` SET `quantite` = '".$ingred_reste[$i]."' WHERE  `nom_objet` ='".$ingredient[$i]."';")or die ("erreur update quantites ingreds :".mysql_error());
    }
    0