Perform calculations when a button is Clicked

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Engr Chidi
Forum Newbie
Posts: 2
Joined: Mon Sep 17, 2012 5:06 am

Perform calculations when a button is Clicked

Post by Engr Chidi »

I intend to do the following, Pls help with the calculation Code:
1. retrieve data from MySQL Table
2. Perform Calculation with the data to get result (to 2 decimal Place)
3.the result is generated when a Button in the Form is Clicked.

The Details are as follows:
Items| Qty | Price | Qty2 | price2 | Amnt | Amnt2 | Pay
Shoe| 2 | 500 | 5 | 700 | x | x | x

The Calculation to perform is:
Amnt = price1 * qty
Amnt2 = price2 * qty2
total = qty1 + qty2
pay = amnt1+amnt2/total

Pay should be in 2 decimal Place, and would be genera when a Button is clicked.

Pls Help with the Calculation and Clicking Code.

Thanks
User avatar
Grizzzzzzzzzz
Forum Contributor
Posts: 125
Joined: Wed Sep 02, 2009 8:51 am

Re: Perform calculations when a button is Clicked

Post by Grizzzzzzzzzz »

what code have you come up with so far?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Perform calculations when a button is Clicked

Post by califdon »

Are you planning to use AJAX or just send a new page? You are aware, I assume, that by the time the browser displays the page with the button, PHP is no longer active, so you can't do anything like this with PHP alone, unless you want to send an entire new page.
Post Reply