Herman Wiid Posted March 13, 2008 Share Posted March 13, 2008 I have a menu, where a user picks a drink and then I want to use that price of the drink to do calculations. Help? Quote Link to comment Share on other sites More sharing options...
maexus Posted March 13, 2008 Share Posted March 13, 2008 Store the price of the drink in a variable? I'm not sure how else you would do something like this. I would honestly consider going over the basics of PHP again. http://hudzilla.org is an amazing resource. Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted March 13, 2008 Share Posted March 13, 2008 it can be in an array, maybe you can put something like this on your form: <input type="checkbox" name="pepsi" value="1.00" />Pepsi<br /> <input type="checkbox" name="coke" value="1.25" />Coke<br /> <input type="checkbox" name="sprite" value="1.50" />Sprite then on the php that processes it just do something like this: <?php $soda['pepsi'] = $_POST['pepsi']; $soda['coke'] = $_POST['coke']; $soda['sprite'] = $_POST['sprite']; foreach($soda as $name => $value){ echo "You purchase a $name for \$$value<br />\n"; } // if you want to add them.... echo "Your total price is ". array_sum($soda); ?> 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.