Jump to content

Help wiht simple print function


bradmoose

Recommended Posts

Ok so its been a while since school and ive forgotton most my php as Ive been more into site building wiht css, html and graphics...

 

<?php

$part=part("");

$size=size("");

$qty=qty("");

if (($part=="2") && ($size=="11") && ($qty=="100"))

echo "Price quote is $59.00"

else if (($part=="2") && ($size=="11") && ($qty=="500"))

echo "Price quote is $99.00"

?>

 

 

my goal is to have a simple form, wiht 3 drop downs qty, size, part are the field names. And depending what options they pick they get a price out put... im missing something so simple, I know it should only take a couple lines of code and simply repeat it wiht else if until you hit the end of all possible options.

 

Can some one please help?  Thanks

Link to comment
https://forums.phpfreaks.com/topic/224215-help-wiht-simple-print-function/
Share on other sites

$_POST['part'], etc.

 

Second thing...I don't think you need all those conditions. The output will be the same for all up until the actual price, so couldn't you just do this:

$price = math done on post variables
echo "Price quote is $".$price;

I see what your saying , but my goal is to have a form wiht 3 drop downs.. 

 

Part - 2 options

Qty - 6 options

Size - 3 options

 

So I want them to be able to pick any combanation of the 3 drop downs and at the bottom of the page in a css box have the php fuction print the price based on the combinantion, unfotuantly there is NO math for this as the prices get better wiht qty... I built a java script that would have worked if it was more mathamatical, but its not.

 

It has to be IF this option + this option + this option are selected then print THISD PRICE....

 

This is where im getting messed up....

 

Thank you all for your fast help...

I see what your saying , but my goal is to have a form wiht 3 drop downs.. 

 

Part - 2 options

Qty - 6 options

Size - 3 options

 

So I want them to be able to pick any combanation of the 3 drop downs and at the bottom of the page in a css box have the php fuction print the price based on the combinantion, unfotuantly there is NO math for this as the prices get better wiht qty... I built a java script that would have worked if it was more mathamatical, but its not.

 

It has to be IF this option + this option + this option are selected then print THISD PRICE....

 

This is where im getting messed up....

 

Thank you all for your fast help...

 

Use a switch staement then, much more efficient.

Hey guys appreciate al the help so far,  Been of the project for a bit...

 

Here is the whole thing so far.....

 

<body>

<?php

 

if (($_REQUEST['part']=="2") && ($_REQUEST['size']=="11") && ($_REQUEST['qty']=="100")){

echo "Price quote is $59.00";}

 

elseif (($_REQUEST['part']=="2") && ($_REQUEST['size']=="11") && ($_REQUEST['qty']=="500")){

echo "Price quote is $99.00";}

 

else {echo "No such Price";

 

?>

<form action="" method="post">

<select name="part">

<option>- Pick One -</option>

<option>2</option>

<option>3</option>

</select>

<select name="size">

<option>- Pick One -</option>

<option>11</option>

<option>2</option>

</select>

<select name="qty">

<option>- Pick One -</option>

<option>100</option>

<option>500</option>

</select>

<input type="submit" value="Get Quote">

<input type="reset" value="Reset!">

</form>

</body>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.