Ok trying to create a query where I get prices of products, multiply them by the quanities wanted, and then add the total...
This is what I have:
$sql = "SELECT ";
$sql.= "item_id, quantity ";
$sql.= "FROM ";
$sql.= "sellIT_cart ";
$sql.= "WHERE ";
$sql.= "user_id = '" . $_SESSION['user_id'] . "'";
$query = mysql_query($sql);
echo '<table width="100%" cellpadding="0" cellspacing="0">';
echo '<tr bgcolor="#CCCCCC">';
echo '<td>Product Id</td>';
echo '<td>Product Name</td>';
echo '<td>Price</td>';
echo '<td>Total Quantity</td>';
echo '<td>New Price</td>';
echo '</tr>';
//for each item, get info
while($row1 = mysql_fetch_array($query))
{
$sql2 = "SELECT ";
$sql2.= "item_name, item_desc, item_product_id, item_shipping_dom, item_shipping_int, item_giftwrap_option, item_giftwrap_total ";
$sql2.= "FROM ";
$sql2.= "sellIT_items ";
$sql2.= "WHERE ";
$sql2.= "item_id = '" . $row1['item_id'] . "'";
$query2 = mysql_query($sql2);
$row2 = mysql_fetch_array($query2);
//Get price
$sql3 = "SELECT ";
$sql3.= "style_price_discount ";
$sql3.= "FROM ";
$sql3.= "sellIT_itemstyles ";
$sql3.= "WHERE ";
$sql3.= "style_item_id = '" . $row1['item_id'] . "'";
$query3 = mysql_query($sql3);
$row3 = mysql_fetch_array($query3);
echo '<tr>';
echo '<td>' . $row2['item_product_id'] . '</td>';
echo '<td>' . $row2['item_name'] . '</td>';
echo '<td>' . $row3['style_price_discount'] . '</td>';
echo '<td>' . $row1['quantity'] . '</td>';
$item_new_price = $row1['quantity'] * $row3['style_price_discount'];
echo '<td>' . $item_new_price . '</td>';
echo '</tr>';
}
This will get the item info, original price, multply price by the quantity wanted. I'm having trouble figuring out a way to add the new price fields to create a grand total.
Like let's say I order 3 of item 1 which costs $5 per item, which is a total of $15, and 10 of item 4 which costs $1 per item, which is $10. How do I get the query to give me a total for all that, which should be $25... ? Thank you.