Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Programming Contests > PHP Programming Contests

PHP Programming Contests Everything to do with the PHP Programming Contests.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2004-09-04, 10:36 AM
Guest_James
Guest
 
Posts: n/a
Default

Hello.

I am new to PHP, and i really need some help. Heres what i am trying to do:

Create a PHP calculator that adds or subtracts user input from a from, for exmaple.

Stage One:

Qty (Form qty box)

A 5" reel (= 4.30) 2
A 6" reel (= 5.30) 1

Stage Two:

Which chemical?

Qty (Form qty box)

DV (2.00) 1
BHS (1.00) 1
STC (3.67)
DVCPRO (1.00) 2

For a working exmaple i found this site, its similar to what i need:

http://www.homemoviedepot.com/calculator.php

I need the script to be able to add up all the unit values and disply them for now, later i need to pass that information to a button or URL but for a start i need to get my head around how to create this script.

Can anyone start me off, (i can create a HTML form and work out my values, but after that my mind fogs) offer any tutorials i should view or advice, anything would be really helpfull i am throwing myself at the mercy of the forum.

Thank you, James.
Reply With Quote
  #2 (permalink)  
Old 2004-12-06, 05:24 AM
Senior Member
 
Join Date: Dec 2004
Posts: 199
strasm is an unknown quantity at this point
Default

Ok, so create a html form.
<form action='calc.php' method='POST'>
<select name='chemical'>
<!--
<option value='2'>DV</option>
<option value='1'>BHS</option>
<option value='3.67'>STC</option>
<option value='1'>DVCPRO</option>

</select>
<input type=text name='qty' value=''>
<input type=sumbit name='submit' value='Submit'>
</form>

I'lll let you do the formatting.

next you need to create the script to process it. This is where it gets tricky. I didnt undestand what you meant when you said this:

Quote:

DV (2.00) 1
BHS (1.00) 1
STC (3.67)
DVCPRO (1.00) 2
I have sort of guessed that the first numbers where the number to be multiplied with the quantity. so here goes with that assumption. Make a file called calc.php, here's what goes inside it:
Quote:

<?
$qty = $_POST[qty];
$chemical = $_POST[chemical];
$total = $qty * $chemical;

?>
<html>
<some decrative junk goes here>


Your total is <? echo $total; ?>

</html>
done!
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.0 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.0 (a popular PHP IDE) and NuCoder 1.4 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:13 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.