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
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;

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

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.