69 users online (0 members and 69 guests)  


  Results 1 to 9 of 9

Related

  1. Replies: 0
  2. Replies: 1
  3. Replies: 4
  4. Replies: 1
  5. Form Handling Script for 'Tell A Friend' Form    Forum: Javascript Forum
    Replies: 1
  1. #1
    Coop's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    22

    Form add up total

    Code:
    <html>
    
     <head>
     </head> 
    
    <body>
     <pre> Welcome to our custom computer ordering page. This page is for Pentium IV everything here is compatable with each other. Happy shopping and have a great day.</pre><br>
     <center><b>Motherboards</b></center>
    <br> <center> ------------------------------------------------------------------------------------------------------------- </center>
    
     <form> 
    <input type="radio" name="mboard" value="189.99">
    DFI LAN Party Pro 875 Socket 478 Motherboard<br>
     <input type="radio" name="mboard" value="59.99">FIC - VI13L - Socket 478 ATX Motherboard with Audio, USB 2.0, AGP 4X, and 10/100Mbps LAN Support<br> 
    </form> 
    </body> 
    </html>
    Ok I have that HTML so far now I will want to add all of their choice's values (there will be more choices)and display the number at the bottom of the screen. How would this be done in PHP? I want it to all add up also onto a paypal button so the total is the same. The button then needs to send me an e-mail stating their choices and take them to the paypal buy page. Please help.

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    You have already asked this question?

    If you want to do it in PHP, thern you need to learn at least the basics first, otherwise anything we say wont make much sense.

    Start with the manual @ http://www.php.net/
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    Coop's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    22

    Thanks but I know the basics

    The subject says it I know the basics already so how would I do the add up I haven't come across anything that would help me do it.

  4. #4
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    fair enough, if your already comfortable with php, then here are the math functions - http://uk.php.net/math

    they have a good explanation of useage with each, just lick on the function.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  5. #5
    Coop's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    22

    ?

    I dont see one for addition am I just not seeing it?

  6. #6
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    oops I sent you to the 'advanced' maths, whic is no good.

    heres a simple example -

    Code:
    $count = 3;
    
    $count = $count + 5;
    
    echo $count;
    that would output 8.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  7. #7
    Coop's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    22

    Thanks

    Ok so I just give each one a variable? How do I insert the variable into each of my parts?

  8. #8
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    PHP can read form variables using the $HTTP_POST_VARS array. So you would use forms for this.

    Read up on forms & variables @ http://www.php.net/
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  9. #9
    christodd's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2003
    Location
    Tacoma, Washington
    Posts
    20
    [QUOTE=Coop]
    Code:
    <html>
     <form> 
    <input type="radio" name="mboard" value="189.99">DFI LAN Party Pro 875 Socket 478 Motherboard<br>
     <input type="radio" name="mboard" value="59.99">FIC - VI13L - Socket 478ATX Motherboard with Audio, USB 2.0, AGP 4X, and 10/100Mbps LAN Support<br> 
    </form>
    When you submit this, mboard will become an Array. To get this array you use the $HTTP_POST_VARS[] global variable.

    Your script would look something like this
    PHP Code:
    <?PHP
    $total
    =0.0;
    $mboard=$HTTP_POST_VARS['mboard'];
    if (!isset(
    $mboard)) //not set
    {
      echo 
    "You chose nothing !!!"
    } else
    {
      if (!
    isarray($mboard)) // they only had one item
      
    {
       
    $total=$mboard;
      }
      else 
      {
        while (list(
    $k,$price)=each($mboard))
        { 
    $total+=$price; }
      }

      echo 
    "Your total is \$ ".$total;
    }
    Hope that helps.

    -Chris
    Last edited by HTML; 10-31-2003 at 05:10 PM.



Tags for this Thread