vjet Posted August 12, 2007 Share Posted August 12, 2007 Hi, I am currently in the process of making an order form although I have come across a small problem. In the order form, you have the option to select which product you are ordering from a drown menu. The value of each item of the menu is that name of the product. This value is then sent to a processing page which emails it to me and the user is then taking to a page in which they can pay for the product using paypal. However, I can find no way of the processing page sending me the price as well. The only way I can think of doing this is making the value for each drop down item the price of the product, but this would mean I do not get to see what the product is called. Your help would be greatly appreciated. Many Thanks, Chris Quote Link to comment https://forums.phpfreaks.com/topic/64547-using-a-drop-down-menu-to-set-the-price/ Share on other sites More sharing options...
nloding Posted August 12, 2007 Share Posted August 12, 2007 If everything is stored in a database, why not do another quick query on the page that emails you the information and pull the price and everything relevant from there. All that needs to be passed from the form page is the amount ordered and the ID/name of the product. Otherwise, use hidden input fields. Quote Link to comment https://forums.phpfreaks.com/topic/64547-using-a-drop-down-menu-to-set-the-price/#findComment-321757 Share on other sites More sharing options...
Psycho Posted August 12, 2007 Share Posted August 12, 2007 Without knowing more about the setup it is impossible to give an appropriate solution. For example, if the products and prices are in a database, your processing page could do a lookup of the price. However, if you are hard-coding all the products and prices, you could make the value something like this "productname|productprice". Then the processing page can split the value based upon the pipe character. Quote Link to comment https://forums.phpfreaks.com/topic/64547-using-a-drop-down-menu-to-set-the-price/#findComment-321759 Share on other sites More sharing options...
vjet Posted August 12, 2007 Author Share Posted August 12, 2007 thankyou for your replies. Although I am not using a database. I am curious to how the | method works. How do you make the processing page choose left or right of the pipe? Quote Link to comment https://forums.phpfreaks.com/topic/64547-using-a-drop-down-menu-to-set-the-price/#findComment-321760 Share on other sites More sharing options...
Psycho Posted August 13, 2007 Share Posted August 13, 2007 Let's assume the field name is "product" and the value selected is "Claw Hammer|9.95" <?php //Convert the "product" value to an array, split on the "|" character $prod_detail = explode('|', $_POST['product']); echo 'Product name: ' . $prod_detail[0]; echo '<br>Product price: ' . $prod_detail[1]; //Output: //Product name: Claw Hammer //Product price: 9.95 ?> Quote Link to comment https://forums.phpfreaks.com/topic/64547-using-a-drop-down-menu-to-set-the-price/#findComment-322130 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.