bradmoose Posted January 12, 2011 Share Posted January 12, 2011 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 Quote Link to comment Share on other sites More sharing options...
Rifts Posted January 12, 2011 Share Posted January 12, 2011 I don't understand $part=part(""); $size=size(""); $qty=qty(""); are part, size, qty functions? Quote Link to comment Share on other sites More sharing options...
bradmoose Posted January 12, 2011 Author Share Posted January 12, 2011 no they are supposed to be var that is gotten from the form fields .... like i said its been close to 3 years since ive done php from scratch.... Quote Link to comment Share on other sites More sharing options...
TOA Posted January 12, 2011 Share Posted January 12, 2011 $_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; Quote Link to comment Share on other sites More sharing options...
bradmoose Posted January 12, 2011 Author Share Posted January 12, 2011 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... Quote Link to comment Share on other sites More sharing options...
TOA Posted January 12, 2011 Share Posted January 12, 2011 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. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 13, 2011 Share Posted January 13, 2011 It would help to see the form you're using. Quote Link to comment Share on other sites More sharing options...
bradmoose Posted January 19, 2011 Author Share Posted January 19, 2011 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> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.