Compile data from multiple tables into 1 cell
Posted: Wed Feb 06, 2008 11:12 pm
Ok, I have a shopping cart I made a few years ago. It stores each item added to a cart in a new table. That table holds the qty and all the other infromation. The problem is some people order 25 to 50 items. So I am ending up thosands of inserts in my cart.
What I want to do is build an array or something and submit all the information including the customers shipping into 1 table.
something like this. saving all the cart information in to $in_my_cart
Should I try an array ... I have tried everything I can think of
Code: Select all
$SQL = "SELECT * FROM CART where goes_with = '$aidd' and sold = 'NO' ORDER by cart_id DESC";
$result = mysql_query( $SQL );
while( $row = mysql_fetch_array( $result ) ) {
$item_name = $row["item_name"];
$item_number = $row["item_number"];
$item_price = $row["item_price"];
$unit_price = $row["unit_price"];
$qty = $row["item_qty"];something like this. saving all the cart information in to $in_my_cart
Code: Select all
$sql = "INSERT INTO SAVE_ORDER SET
save_order_id = '$new_order_id', goes_with = '$muser',
order_ip = '$order_ip' , [color=#BF0000][b]in_my_cart = '$in_my_cart' ,[/b][/color]
order_date = '$order_date' , account_firstname = '$account_firstname' ,
account_lastname = '$account_lastname' , account_email = '$account_email' ,
account_phone = '$account_phone' , account_address = '$account_address' ,
account_address_two = '$account_address_two' , account_city = '$account_city' ,
account_state = '$account_state' , account_zip = '$account_zip' ,
shipping_firstname = '$shipping_firstname' , shipping_lastname = '$shipping_lastname' ,
shipping_email = '$shipping_email' , shipping_phone = '$shipping_phone' ,
shipping_address = '$shipping_address' , shipping_address_two = '$shipping_address_two' ,
shipping_city = '$shipping_city' ,
shipping_state = '$shipping_state' , shipping_zip = '$shipping_zip' ,
order_total = '$order_total' ,
order_sub_total = '$order_sub_total' , coupon_used = '$coupon_used' ,
coupon_percent = '$coupon_percent' ,
shipping_type = '$shipping_type' ,
shipping_price = '$shipping_price' ,
tax_percent = '$tax_percent' ,
tax_amount = '$tax_amount'";
$query = mysql_query($sql) or die("Cannot query the database." . mysql_error());
Should I try an array ... I have tried everything I can think of