MsKazza Posted March 16, 2011 Share Posted March 16, 2011 Hi there, I'm coding a products page (pls see : http://agraphics.ie/products.php?recordID=4) so far i have it picking up the products from the database, filtering categories via the menu, and then product weight and quantity on the page. My problem is that i need to display the price at the bottom and also have it add or take away 49€ depending on the radio button. Any help much appreciated as i'm running out of time. I tried experts-exchange but so far nothing from them. Thanks in advance for any help. MsKazza Link to comment https://forums.phpfreaks.com/topic/230839-calculating-prices-and-displaying-price/ Share on other sites More sharing options...
litebearer Posted March 16, 2011 Share Posted March 16, 2011 Seeing the code is MORE helpful than seeing the output Link to comment https://forums.phpfreaks.com/topic/230839-calculating-prices-and-displaying-price/#findComment-1188341 Share on other sites More sharing options...
MsKazza Posted March 16, 2011 Author Share Posted March 16, 2011 please find attached products.php thanks, this is an example of the functionality : http://cypherstore.co.uk/product_info?c_product_id=214 [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/230839-calculating-prices-and-displaying-price/#findComment-1188344 Share on other sites More sharing options...
MsKazza Posted March 16, 2011 Author Share Posted March 16, 2011 Sorry i forgot to add this last time, an example price list. thanks, MsKazza [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/230839-calculating-prices-and-displaying-price/#findComment-1188387 Share on other sites More sharing options...
darkfreaks Posted March 16, 2011 Share Posted March 16, 2011 could try something like..... <?php $available_options = array("op1_value"=>"Option 1", "op2_value"=>"Option 2", "op3_value"=>"Option 3", "op4_value"=>"Option 4", "op5_value"=>"Option 5", "op6_value"=>"Option 6", ); $processing_message = ''; if (isset($_POST['option_choice'])) { switch ($_POST['option_choice']) { case 'op1_value': $processing_message = 'Nice choice!'; break; case 'op2_value': $processing_message = 'Good choice.'; break; case 'op3_value': $processing_message = 'OK choice.'; break; case 'op4_value': $processing_message = 'Moderate choice.'; break; case 'op5_value': $processing_message = 'Horrible choice.'; break; default: $processing_message = 'Incorrect'; //In this example, either op6_value is chosen, or something else was entered (say through a hack of the form) break; } } if (strlen($processing_message) > 0) { echo '<div class="processing_message">'.$processing_message.'</div>'; } echo '<form method="post" action="'.basename(__file__).'">'; foreach($available_options as $option_value=>$option_label) { //Notice the use of the ternary operator ()?: to check the selected radio button after the form was submitted. echo $option_label.'<input type="radio" name="option_choice" value="'.$option_value.'" '.(($option_value == $_POST['option_choice'])?' checked="checked"':'').'/><br />'; } echo '<input type="submit" value="Check Answer" />'; echo '</form>'; ?> then in the option you want to it to subtract from just put $total price minus 45 where $message is supposed to go under the case. Link to comment https://forums.phpfreaks.com/topic/230839-calculating-prices-and-displaying-price/#findComment-1188435 Share on other sites More sharing options...
MsKazza Posted March 17, 2011 Author Share Posted March 17, 2011 thank you but i don't see how that applies to what i'm asking, i have three drop down boxes on my page, product, weight and quantity. I want to use the dropdowns to filter the recordset, so choosing a specific product will filter down to only the weight and quantities possible for that product, then when they choose weight and quantity it will display the price for that specific product at the end of the page. Please help urgent. I have to get this done today, one way or another. Thanks MsKazza Link to comment https://forums.phpfreaks.com/topic/230839-calculating-prices-and-displaying-price/#findComment-1188612 Share on other sites More sharing options...
darkfreaks Posted March 17, 2011 Share Posted March 17, 2011 if you want to change the price button on select you need to find a javascript function (google) that onclick of the selected text will change the button. this is not a PHP matter. somthing like below should work on select it will go to a new page. http://www.codeproject.com/KB/scripting/autoselect.aspx Link to comment https://forums.phpfreaks.com/topic/230839-calculating-prices-and-displaying-price/#findComment-1188808 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.