Jump to content

Tricky problem...


nikefido

Recommended Posts

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!!!!!)

Link to comment
https://forums.phpfreaks.com/topic/92364-tricky-problem/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/92364-tricky-problem/#findComment-473288
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.