refael Posted November 2, 2009 Share Posted November 2, 2009 Hi I hope somone can just help me bring this to work. In a web form i added a multiple select option like so: <select name="product[]" multiple="multiple" ...> in the php file that sends the info to my email i simply added this: $product = $_POST['product']; to the $body i simply added $product $body = " Name - $ime \n \n \n Business - $business \n \n \n Email Address - $email \n \n \n Print Product(s) - $products.[] \n \n \n Budget - $budget \n \n \n Comment - $comment \n \n \n IP - $ip"; that obviously does not work. i am sure i need to loop in an array but have no idea how to so i added this: $products = array( 'product1' => 'product1', 'product2' => 'product2', ................ ); what's next? can someone help me PLEASE? Link to comment https://forums.phpfreaks.com/topic/179900-multiple-select-options-to-email/ Share on other sites More sharing options...
taquitosensei Posted November 2, 2009 Share Posted November 2, 2009 foreach($_POST['product'] as $product) { // do whatever with each product selected } Link to comment https://forums.phpfreaks.com/topic/179900-multiple-select-options-to-email/#findComment-949008 Share on other sites More sharing options...
refael Posted November 2, 2009 Author Share Posted November 2, 2009 foreach($_POST['product'] as $product) { // do whatever with each product selected } hi thanks!!! how can i add this to the $body? Link to comment https://forums.phpfreaks.com/topic/179900-multiple-select-options-to-email/#findComment-949033 Share on other sites More sharing options...
mikesta707 Posted November 2, 2009 Share Posted November 2, 2009 concatenate a string. $products = ""; foreach($_POST['product'] as $product) { $products .= $products . " "; } that will put your products in a line with each one seperated by a space, IE shirt pants dog cat sandwhich. you could then use the $products variable in your body Link to comment https://forums.phpfreaks.com/topic/179900-multiple-select-options-to-email/#findComment-949037 Share on other sites More sharing options...
refael Posted November 2, 2009 Author Share Posted November 2, 2009 mikesta707 i really do thank you but it does not work! let me just repeat ok? in the form i have this: select name="product[]" multiple="multiple" size="10" in the mail php i have this: $product = $_POST['product']; $products = array( 'prod1' => 'prod1', 'prod2' => 'prod2' ); $products = ""; foreach($_POST['product'] as $product) { $products .= $products . " "; } $body = $products (this should print the products selected in the email) thanks!!!! Link to comment https://forums.phpfreaks.com/topic/179900-multiple-select-options-to-email/#findComment-949058 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.