yarub Posted August 28, 2008 Share Posted August 28, 2008 Hey there. I can't seem to find what I'm looking for by searching because I apparently don't know what to search. What I have is a list of rows where clients can select an item and how many they want of the item. It would then create a row in a table saying that they want x amount of Item X. Each of these items also have a price, and that's ultimately what I'm trying to add up. However, the part that I'm having trouble with is getting it to see that there are quantities. Here is an example... QTY | Item | Price | Price * QTY 1 | Item | $10 | $10 3 | Item | $5 | $15 1 | Item | $50 | $50 6 | Item | $25 | $150 [/td] [td] | Sub | ?? I want to know how to get the answer for the ?? in there. I basically have a result to get each of the "Price * QTY"s, but I can't figure out how to add them together. $i = 0; $query3 = mysql_query("select * FROM items WHERE oid='$id'"); while($item = mysql_fetch_array($query3)){ $i++; $price = $item['price']; $quantity = $item['quantity']; $pricexqty = $price * $quantity; Quote Link to comment https://forums.phpfreaks.com/topic/121642-adding-up-fields-from-multiple-results-w-multiple-quantities/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.