nikefido Posted February 21, 2008 Share Posted February 21, 2008 I have this query: $myQuery = "SELECT i.transportation, i.delivery, i.total, i.charge_amount1, i.charge_amount2, j.charge_amount "; $myQuery .= "FROM invoice i, invoice_charges j "; $myQuery .= "WHERE i.bol = {$bolID} AND j.bol = {$bolID}"; Now, this is within a while loop for a result set (so within the result set of a query, i am running this query on each result) - therefore $bolID is constantly changing. Anyway, I get multiple results from the query above where the $bolID is the same. For instance: 1:::777579====77=====97====445.63 2:::777579====77=====97====433.85 1:::777370====77=====222====257.83 2:::777370====77=====222====271.25 3:::777370====77=====222====263.43 1:::777621====77=====77====193.6 Is an echo of some results. The longer numbers beginning with "777" is the $bolID. I need to add all the right hand most numbers that have the same $bolID. How can I accomplish this? (for the record, i really REALLY hate dealing with other people's code!!!!!) Quote Link to comment Share on other sites More sharing options...
drisate Posted February 22, 2008 Share Posted February 22, 2008 sorry i don't understand a thing from your question lol "I need to add all the right hand most numbers that have the same $bolID." For your record i hate dealing with hard to understand questions hehe try to explain your self a little more. Quote Link to comment Share on other sites More sharing options...
Barand Posted February 22, 2008 Share Posted February 22, 2008 I'm puzzled - how does the bolID appear in the results when it isn't selected in the query? Quote Link to comment Share on other sites More sharing options...
mem0ri Posted February 22, 2008 Share Posted February 22, 2008 Add a loop that goes something like... while($row = mysql_fetch_array($result)) $total_charge += $row['charge_amount']; ...since your query is looping (ouch), I'll assume that you're echoing the DB results in each loop...so if you just echo-out total charge during that process and then reset it to 0 with the next loop...you should be fine. Quote Link to comment Share on other sites More sharing options...
Barand Posted February 22, 2008 Share Posted February 22, 2008 That give a single total for all rows - at least it did before your edit Quote Link to comment 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.