Jump to content

calculate price


boontoony

Recommended Posts

Hi,

I was wondering if i could get some help on this form. I am basically calculating an amount of metres by the price per metre.

 

I have the form set up, below, but need help actually processing the calculation. How do i echo the following on "calculate_price.php".

 

example

 

20 metres (which was selected from the drop down menu) = $the price of metres

 

Any help would be appreciated.

 

<form method="post" action="calculate_price.php">
  <td align="left" valign="top" class="content"><table border="0">
      <tr>
        <td nowrap>Metres</td>
        <td><select name="metres" style="width:100px; ">
            <option value="15">15</option>
            <option value="20">20</option>
            <option value="25">25</option>
            <option value="30">30</option>
            <option value="35">35</option>
            <option value="40">40</option>
            <option value="45">45</option>
            <option value="50">50</option>
            <option value="55">55</option>
            <option value="60">60</option>
            <option value="65">65</option>
            <option value="70">70</option>
            <option value="75">75</option>
            <option value="80">80</option>
          </select></td>
      </tr>
    </table>
    <input name="type" type="radio" value="24">
    ex 1 - $24 per metre<br>
    <input name="type" type="radio" value="27">
    ex 2 - $27 per metre<br>
    <input name="type" type="radio" value="28">
    ex 3 - $28 per  metre<br>
    <input name="type" type="radio" value="30">
    ex 3 – $30 per metre<br>
    <input type="submit" name="Submit" value="Calculate">
</form>

 

Link to comment
Share on other sites

 

is this what you're looking for?

 

<?php

$price = $_POST['metres'] * $_POST['type'];

echo 'The price for ' . $_POST['metres'] . ' metres at $' . $_POST['type'] . ' per metre comes to a total of $' . $price . '.';

?>

 

this should calculate your price, just make sure you validate your form data for security reasons

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.