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?

Inspiring
March 27, 2012

so i need to know what goes where.

>I thought I just showed you?

but this is the equation, how does this actually get the information to the page?

>I'm not following you. These are calculated values. Why do you need to send them to the database?

ok once the option is selected this figures need to be stored so they can be retrieved on the next page so as to make payment?


it might be easier to show you the part of the page of what needs to go where

application page this is where the rental price and the duration(actually called weeks) comes from part code ( not all the INSERT ) the rental price comes from another table that is link via the value prop_id)

$insertSQL = sprintf("INSERT INTO plus_signup (prop_id,weeks) VALUES (%s, %s)",

GetSQLValueString($_POST['prop_id'], "text"),

GetSQLValueString($_POST['weeks'], "text"));

form values

<input name="rental_price" type="text" id="rental_price" size="30" readonly="readonly" />

<input type="radio" value="364" name="weeks" />

<input type="radio" value="301" name="weeks" />

the next page is where they chose there option

The Rent and duration are in a table

<td width="162" class="table-text"><?php echo $row_Recordset1['rental_price']; ?></td>

<td class="table-text"><?php echo $row_Recordset1['weeks']; ?></td>

i have then created hidden DIV to show thedifferent values

table is below. this is what i thought needed to be sent to the DB in order to store the values

<table width="980" cellspacing="0" cellpadding="0">

  <tr valign="top">

    <td height="69" bgcolor="#B6EB2B" class="table-text"><div align="center">

      <p>4 weeks</p>

      <p> Security <br />

        Depost</p>

    </div></td>

    <td height="69" bgcolor="#B6EB2B" class="table-text"><div align="center">

      <p>52 weeks </p>

      <p>payable</p>

    </div></td>

    <td height="69" bgcolor="#B6EB2B" class="table-text"><div align="center">Fee</div></td>

    <td height="69" bgcolor="#B6EB2B" class="table-text"><div align="center">

      <p>52 Weeks </p>

      <p>payable<br />

        inc</p>

      <p> fee & SD</p>

    </div></td>

    <td height="69" bgcolor="#B6EB2B" class="table-text"><div align="center">

      <p>Initial</p>

      <p> Holding</p>

      <p> Deposit</p>

    </div></td>

    <td height="69" bgcolor="#B6EB2B" class="table-text"><div align="center">

      <p>Initial </p>

      <p>Payment 15 </p>

      <p>weeks </p>

      <p>15w+f+sd</p>

    </div></td>

    <td height="69" bgcolor="#B6EB2B" class="table-text"><div align="center">

      <p>Balance </p>

      <p>due </p>

      <p>before </p>

      <p>moving in</p>

    </div></td>

    <td height="69" bgcolor="#B6EB2B" class="table-text"><div align="center">

      <p>Second </p>

      <p>payment </p>

      <p>14 weeks</p>

    </div></td>

    <td height="69" bgcolor="#B6EB2B" class="table-text"><div align="center">

      <p>Third </p>

      <p>Payment </p>

      <p>14 weeks</p>

    </div></td>

    <td height="69" bgcolor="#B6EB2B" class="table-text"><div align="center">

      <p>Fourth </p>

      <p>payment </p>

      <p>9 weeks</p>

    </div></td>

    <td bgcolor="#B6EB2B" class="table-text">Total Payment</td>

  </tr>

  <tr>

    <td height="38" colspan="11" align="center"><form name="form1" method="post" action="">

      <table width="100%" border="0" cellspacing="0" cellpadding="5">

        <tr>

          <td><table width="100%" cellspacing="0" cellpadding="0">

            <tr>

              <td align="center"><div align="center">

                <input name="SecDeposit" type="text" size="8" />

                <br />

              </div></td>

            </tr>

            <tr>

              <td height="30"><div align="center"></div></td>

            </tr>

          </table></td>

          <td><table width="100%" cellspacing="0" cellpadding="0">

            <tr>

              <td align="center"><div align="center">

                <input name="WeeksPayable" type="text" size="8" />

                <br />

              </div></td>

            </tr>

            <tr>

              <td height="30"><div align="center"></div></td>

            </tr>

          </table></td>

          <td><table width="100%" cellspacing="0" cellpadding="0">

            <tr>

              <td align="center"><div align="center">

                <input name="Fee" type="text" size="8" />

                <br />

              </div></td>

            </tr>

            <tr>

              <td height="30"><div align="center"></div></td>

            </tr>

          </table></td>

          <td><table width="100%" cellspacing="0" cellpadding="0">

            <tr>

              <td align="center"><div align="center">

                <input name="FeeIncl" type="text" id="BalanceDue8" size="8" />

                <br />

              </div></td>

            </tr>

            <tr>

              <td height="30"><div align="center"></div></td>

            </tr>

          </table></td>

          <td><table width="100%" cellspacing="0" cellpadding="0">

            <tr>

              <td align="center"><div align="center">

                <input name="HoldingDep" type="text" size="8" />

                <br />

              </div></td>

            </tr>

            <tr>

              <td height="30"><div align="center"></div></td>

            </tr>

          </table></td>

          <td><table width="100%" cellspacing="0" cellpadding="0">

            <tr>

              <td align="center"><div align="center">

                <input name="Initial" type="text" size="8" />

                <br />

              </div></td>

            </tr>

            <tr>

              <td height="30"><div align="center"></div></td>

            </tr>

          </table></td>

          <td><table width="100%" cellspacing="0" cellpadding="0">

            <tr>

              <td align="center"><div align="center">

                <input name="MovBal" type="text" size="8" />

                <br />

              </div></td>

            </tr>

            <tr>

              <td height="30"><div align="center"></div></td>

            </tr>

          </table></td>

          <td><table width="100%" cellspacing="0" cellpadding="0">

            <tr>

              <td align="center"><div align="center">

                <input name="SecPay" type="text" size="8" />

                <br />

              </div></td>

            </tr>

            <tr>

              <td height="30"><div align="center"></div></td>

            </tr>

          </table></td>

          <td><table width="100%" cellspacing="0" cellpadding="0">

            <tr>

              <td align="center"><div align="center">

                <input name="thirdPay" type="text" size="8" />

                <br />

              </div></td>

            </tr>

            <tr>

              <td height="30"><div align="center"></div></td>

            </tr>

          </table></td>

          <td><table width="100%" cellspacing="0" cellpadding="0">

            <tr>

              <td align="center"><div align="center">

                <input name="fourthPay" type="text" size="8" />

                <br />

              </div></td>

            </tr>

            <tr>

              <td height="30"><div align="center"></div></td>

            </tr>

          </table></td>

          <td><table width="100%" cellspacing="0" cellpadding="0">

            <tr>

              <td align="center"><div align="center">

                <input name="fullpayment" type="text" size="8" />

                <br />

              </div></td>

            </tr>

            <tr>

              <td height="30"><div align="center"></div></td>

            </tr>

          </table></td>

        </tr>

      </table>

    </form></td>

  </tr>

</table>

i need to add a submit button

but the thing is they have even chosen 43 or 52 weeks so should i make a table (total of 6 for each option)

and we have the equations

$monthly = $sql_row["montly_rent"];

$deposit = $monthly * 4

$payable=$monthly *52 and so on...

how do i get this working to show in the tables

we then have the final screen where they make the payments

it will be the same as the above table but under Balance Due, second payment, third payment and fourth payment there will be a pay button.

Also this needs to be deducted off the total when payments are made