Hello,
I am writing a piece of PHP software (with MySQL, APACHE) to automate the billing for my web server.
I set-up a web interface where I specify the billing period by month/year and press a submit button to activate invoices e-mailed to all customers. My problem relates to calculating the fee for the billing period. If the domain has never been billed before, I want the software to bill the monthly_fee + setup_fee ... if the domain has been billed before, the software should only bill the monthly_fee.
I store my data in two tables:
domain_info
+---------------------+--------------+
| domain_id | int(11) |
| domain_name | varchar(70) |
| login | varchar(8) |
| password | varchar(8) |
| first_name | varchar(128) |
| last_name | varchar(128) |
| company_name | varchar(128) |
| address1 | varchar(128) |
| address2 | varchar(128) |
| city | varchar(128) |
| state | char(2) |
| zip | varchar(10) |
| phone | varchar(12) |
| email | varchar(128) |
| billing_cycle | char(2) |
| date_opened | timestamp(6) |
| setup_fee | float(10,2) |
| monthly_fee | float(10,2) |
| service_description | text |
+---------------------+--------------+
billing_info
+-------------+--------------+
| invoice_id | int(11) |
| domain_id | int(11) |
| ammount_due | float(10,2) |
| date_due | timestamp(6) |
| status | int(1) |
+-------------+--------------+
I want to create a loop the gets info from the domain_info table and inserts it into the billing_info table ... but i first need to check and see if anyting exists for the domain in the billing_info table in order to calculate the ammount_due. How do I do this?
Help!
Nick