Google Answers Logo
View Question
 
Q: Basic PHP script ( Answered,   0 Comments )
Question  
Subject: Basic PHP script
Category: Computers > Programming
Asked by: marcus_venturi-ga
List Price: $20.00
Posted: 19 Nov 2004 16:29 PST
Expires: 19 Dec 2004 16:29 PST
Question ID: 431303
Hi!

I'ld need a clean PHP script (output.php) that, given the following
input page (input.htm) where the user select the weight and volume of
a package to be shipped, returns the prices of various couriers
("yellow", "blue" and "black").
 
~~~ input page input.htm:

<form method="GET" action="output.php" name="input">

SELECT THE VOLUME OF YOUR PACKAGE: 

	<input type="radio" name="volume" value="1"> from 0 to 1 m3
	<input type="radio" name="volume" value="2"> from 1 to 2 m3
	<input type="radio" name="volume" value="3"> from 2 to 3 m3

<br>SELECT THE WEIGHT OF YOUR PACKAGE:

	<input type="radio" name="weight" value="100"> from 0 to 100 Kg
	<input type="radio" name="weight" value="200"> from 100 to 200 Kg
	<input type="radio" name="weight" value="300"> from 200 to 300 Kg

</form>

~~~ istructions to be integrated in the "output.php" script:

 Courier "yellow" - for volume 1, 2 and 3:
  if weight=100 then rate=600
  if weight=200 then rate=900
  if weight=300 then rate=1200

 Courier "blue" - for volume 1 and 2: 
  if weight=100 then rate=400
  if weight=200 then rate=700

 Courier "black" - for volume 2 and 3: 
  if weight=100 then rate=800
  if weight=200 then rate=1100
  if weight=300 then rate=1500


~~~ sample request and result:

Example A) With the user input:
 volume=2
 weight=300

output.php must generate this result:
 courier "yellow" = 1200
 courier "black" = 1500


Example B) With the user input:
 volume=1
 weight=100

output.php must generate this result:
 courier "yellow" = 600
 courier "blue" = 400



After this basic script, I'll probably post new questions for some extensions.

Thanks,
Marcus
Answer  
Subject: Re: Basic PHP script
Answered By: googleexpert-ga on 20 Nov 2004 07:59 PST
 
Hi marcus_venturi-ga,
Here is the basic PHP script with some modifications to input.htm
File: input.htm                                                          

<form method="GET" action="output.php" name="input"> SELECT THE VOLUME
OF YOUR PACKAGE:
        <input type="radio" name="volume" value="1"> from 0 to 1 m3
        <input type="radio" name="volume" value="2"> from 1 to 2 m3
        <input type="radio" name="volume" value="3"> from 2 to 3 m3
<br>SELECT THE WEIGHT OF YOUR PACKAGE:
        <input type="radio" name="weight" value="100"> from 0 to 100 Kg
        <input type="radio" name="weight" value="200"> from 100 to 200 Kg
        <input type="radio" name="weight" value="300"> from 200 to 300 Kg
        <br />
        <input type="Submit" name="Submit" value="Submit">
</form>


File: output.php
<?php

$volume = $_GET["volume"];
$weight = $_GET["weight"];

$couriers["1"]["100"] = "Courier 'Yellow' = 600<br />Courier 'Blue' = 400";
$couriers["1"]["200"] = "Courier 'Yellow' = 900<br />Courier 'Blue' = 700";
$couriers["1"]["300"] = "Courier 'Yellow' = 1200";

$couriers["2"]["100"] = "Courier 'Yellow' = 900<br />Courier 'Blue' =
400\nCourier 'Black' = 800";
$couriers["2"]["200"] = "Courier 'Yellow' = 900<br />Courier 'Blue' =
700\nCourier 'Black' = 1100";
$couriers["2"]["300"] = "Courier 'Yellow' = 1200<br />Courier 'Black' = 1500";

$couriers["3"]["100"] = "Courier 'Yellow' = 600<br />Courier 'Black' = 800";
$couriers["3"]["200"] = "Courier 'Yellow' = 900<br />Courier 'Black' = 1100";
$couriers["3"]["300"] = "Courier 'Yellow' = 1200<br />Courier 'Black' = 1500";

print $couriers[$volume][$weight];
?>

Please let me know if you have any questions.
Thank you.

-googleexpert
Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy