masterchiller Posted March 9, 2006 Share Posted March 9, 2006 I'm using the following code;[code]<?phpforeach ($_SESSION['ordered_articles'] AS $array){$articlenumber = $array['artnumber'];$articleamount = $array['amount'];}$mysql_query = "INSERT INTO `orders` values ('NULL', '$articlenumber', '$articleamount')";$result = mysql_query($mysql_query);?>[/code]This code puts the array in the database. But when I have more than one article in my array, it just ads one article in the database, instead of them all.What am I doing wrong here ? Quote Link to comment Share on other sites More sharing options...
Barand Posted March 9, 2006 Share Posted March 9, 2006 The mysql insert also needs to be inside the foreach loop[code]foreach ($_SESSION['ordered_articles'] AS $array){ $articlenumber = $array['artnumber']; $articleamount = $array['amount']; $mysql_query = "INSERT INTO `orders` values ('NULL', '$articlenumber', '$articleamount')"; $result = mysql_query($mysql_query);}[/code] Quote Link to comment Share on other sites More sharing options...
masterchiller Posted March 9, 2006 Author Share Posted March 9, 2006 Thank you !! This really worked for me! =)I was looking for a while loop or something, but this is a much easier and better solution ;). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.