Jump to content

Help with looping session items into database


phpdragon

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.