phpdragon Posted February 22, 2009 Share Posted February 22, 2009 I have been looking at several loops and I dont seem to be able to work out where I am going wrong. I am trying to go thru my session array and add the items to my orders table, but I am only geting the first row and then an error on the second row appears in the browser. The code I have to do the loop is $orderTable=$userID."_orders"; for ($basket_counter=0; $basket_counter<$ses_basket_items; $basket_counter++){ $price=sprintf("%01.2f",$ses_basket_price[$basket_counter]); $quantity=$ses_basket_amount[$basket_counter]; $code=$ses_basket_stockcode[$basket_counter]; $itemID=$ses_basket_id[$basket_counter]; $product=$ses_basket_name[$basket_counter]; $unit=sprintf("%01.2f",($price/$quantity)); // add item to users order table $sql="INSERT INTO $orderTable VALUES ('".mysql_real_escape_string($thisID)."', '".mysql_real_escape_string($product)."', '".mysql_real_escape_string($itemID)."', '".mysql_real_escape_string($quantity)."', '".mysql_real_escape_string($code)."', '".mysql_real_escape_string($unit)."')"; $result=mysql_query($sql) or die ("Error in query: $sql"); } can anyone tell me what I am missing to make it scrool thru the loop tku. Link to comment https://forums.phpfreaks.com/topic/146325-help-with-looping-session-items-into-database/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.