You are missing loading the $i item of the $Session_variable_with_itemID into $ses_basket_id' before doing the insert. Satyam "Mayo" <mayo@xxxxxxxxxxxxxxxxxx> wrote in message news:000001c55c2d$e7749c70$259b1d18@xxxxxxxxxxxxxxxxx > I'm putting ordered items into a db. The information is stored in > session variables. > > Session_variable_with_itemID_has(1001,1002,1003,1004) however when > inserted into the db only 0,0,0,0 is recorded. > > Assuming that this was the 40th recorded order the table should look > like this > > TABLE: orderedItems > > orderedItemsID -- orderID - itemID > > 159 - 40 - 1001 > 160 - 40 - 1002 > 161 - 40 -- 1003 > 162 - 40 - 1004 > > What comes out is: > > orderedItemsID -- orderID - itemID > > 159 - 40 - 0 > 160 - 40 - 0 > 161 - 40 -- 0 > 162 - 40 - 0 > > > The loop itself works as intended. However it is not inserting this > variable. > > $ses_basket_items is the total number of items > $orderID = the orderID which these items are a part of > $ses_basket_id = is the itemID number > > > > for ($i=0;$i<$ses_basket_items;$i++){ > > $query = "INSERT INTO orderedItems (orderID,itemID) VALUES > ('$orderID','$ses_basket_id')"; > > mysql_query($query) or die('Error, insert query failed'); > > } > > mysql_close($conn); > > thx > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php