Skip to main content
Inspiring
March 26, 2012
Question

equations using php and / or javascript

  • March 26, 2012
  • 1 reply
  • 1950 views

i have a excel spreadsheet that has a basic - input one amount in column A then it adds column A to Column C to give Col D results. Well thats the rough idea.,

to basically a field comes from a mysql database then need to start the equation ( the field from the DB would be COL A)

what is the best way to do this?

This topic has been closed for replies.

1 reply

Participating Frequently
March 26, 2012

If the user is simply going to enter a single value and get the results, I would use php. If it's going to be more interactive - like they may try lots of different values, then javascript will provide a better user experience.

Inspiring
March 26, 2012

ok it is basically one amount coming from the DB and a fixed equation. What do i need to do to get going on this? are there any good tutorials out there?

Participating Frequently
March 26, 2012

well i will explain what i am trying to achieve and see if it is more complex than i imagined

the user first selects a property, the monthly rental that they select e.g 98.00 is passed to a column in the database called RENT they then select how long they will be in the property, either 43 or 52 weeks again this information is sent to another field called DURATION

when they log into there page they are given 4 payment options 1 is termly option 2 is loan option 3 is monthly and option 4 is annual

they then select which option they will pay with (the is fixed) they are then directed to the final page where they make the payments for that option.

option 1 is for the 52 weeks

D in pulled in from the database e.g 98.00

E shows =D * 4

F shows =D * 52

G shows a fixed fee e.g 184.00

H shows =E + F + G

I shows =(D*15)+G+E

J shows =D*14

K shows =D*14

L shows =D*9

M showsa = =I+J+K+L

there are 6 tables total 3 for 43 weeks and 3 for 52 weeks

i think if i am shown 1 i can figure the rest out

is this way over my head??


>is this way over my head??

No. It's much easier than you think. Assuming you have already retrieved the SQL record

$D = $sql_row["montly_rent"];

$E = $D * 4

$F = $D * 52

$G = 184

$H = $E + $F + $G

$I = ($D * 15) + $G + $E

....you get the idea. Of course, use meaningful variable names, not the simple letters I used for an example.