Forum Moderators: coopster
[2]$query = "INSERT INTO orders VALUES ('order_id','$item1','$item2','$item3','$subtotal','$shipping','$total')";[/2] where $item# is actually the qty of product item ordered, then I can cross-reference against the products table and create a report and output the HTML
What I really need to do is post each product ordered to it's own table row...in other words, to create a row entry for each item ordered with fields like :
order_id ¦ item_num ¦ item_descr ¦ item_qty ¦ item_price ¦ item_total
this would give me a table that reads something like:
101 ¦ paint ¦ 5 gallon pail ¦ 2 ¦ 25.00 ¦ 50.00
101 ¦ brush¦ 2 inch broad ¦ 2 ¦ 10.00 ¦ 20.00
101 ¦ paint ¦ 1 gallon pail ¦ 3 ¦ 12.50 ¦ 37.50
(obviously I would have to include additional fields to those above)
can this be done?
I'm wondering how to write the INSERT INTO query so that it posts each item ordered across the row, then moves to the next row to enter the next item ordered, for as many items ordered?
hope this makes sense..
any/all help appreciated.
thanks in advance.
mc
All you have to do now is loop through all the items and do the following:
for($i=0;$i<count($items_array);$i++){
// Do your insert query and relate the info to the order id
// This is just an example to insert the item(s) only
$query = "insert into db set item = ".$items_array[$i];
$rs = mysql_query($query);
}
Of course you will want to save all the values you need so add them to the query :-)
Once you do that loop you will have an entry for each item no matter how many there are and they will be related to the order id.
JAG