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? Link to comment https://forums.phpfreaks.com/topic/96044-arrays/ 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. Link to comment https://forums.phpfreaks.com/topic/96044-arrays/#findComment-491700 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); ?> Link to comment https://forums.phpfreaks.com/topic/96044-arrays/#findComment-491747 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.