This topic is locked

Using events to get totals of two tables

4/10/2006 4:00:53 PM
PHPRunner General questions
D
Dale author

Can anyone help me here.

I have looked through the samples and have been researching the web for an hour or so on this issue. I believe the answer to my need will be fairly simple.
I have a purchases table and a payments table. both linked to the customer table.

When creating a payment for this customer -

Using the Event on Add page: OnLoad

I would like to

  1. Get the total of all purchases for this client. Place this value in a $total_purchases variable.
  2. Get the total of all payments for this client. Place this value in a $total_payments variable.
    Then I will just Subtract the $total_payments from the $total_purchases and auto fill the

    amount field on the payment form.
    If someone could give me an example on how I would make one of the queries I would be greatful.

    Im hoping that I can make both queries on the onload and help with automating the payment form.
    Any help or pointers will be greatly appreciated.