Re: multiple inserts into a db

From: Date: Thu, 19 May 2005 11:24:19 +0000
Subject: Re: multiple inserts into a db
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-215580@lists.php.net to get a copy of this message
You are missing loading the $i item of the $Session_variable_with_itemID into $ses_basket_id' before doing the insert. Satyam "Mayo" <mayo@nycinteractive.com> wrote in message news:000001c55c2d$e7749c70$259b1d18@ghcm7sj76pvb9b... > 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 > >

« previous php.general (#215580) next »