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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.