NathanS Posted December 19, 2007 Share Posted December 19, 2007 Hi guys, I've created a web based form which emails the results. However, I've now got a multiple select form, and I'm trying to make the email echo the output of that (ie, however many have been selected) $msg .= "<b>Modified Yes Details</b>: "foreach($_POST['MODIFIEDYES'] as $name) { echo $name; }" "\n"; however, PHP returns "unexpected T_FOREACH". Any way I can achieve this? Thanks! Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 19, 2007 Share Posted December 19, 2007 should be $msg .= "Modified Yes Details: ".implode("\n",$_POST['MODIFIEDYES'])."\n"; Quote Link to comment Share on other sites More sharing options...
NathanS Posted December 19, 2007 Author Share Posted December 19, 2007 thanks for your fast reply, much appreciated! i get: Warning: implode() [function.implode]: Bad arguments. in C:\Websites\www.hertsinsurance.com\epasend.php on line 225 when I try this now - any ideas? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 19, 2007 Share Posted December 19, 2007 is $_POST['MODIFIEDYES'] an array ? Quote Link to comment Share on other sites More sharing options...
NathanS Posted December 19, 2007 Author Share Posted December 19, 2007 yes it is, my html code is: <select name="MODIFIEDYES[]" size="10" multiple> <?php while($noticia = mysql_fetch_array($vehiclemod)) { echo "<option value='$noticia[VEHICLE_MOD_DEBUG]'>$noticia[VEHICLE_MOD_DEBUG]"; } ?> </select> thanks Quote Link to comment Share on other sites More sharing options...
chigley Posted December 19, 2007 Share Posted December 19, 2007 Well your HTML is invalid for a start. You need a </option> closing tag. Quote Link to comment Share on other sites More sharing options...
NathanS Posted December 19, 2007 Author Share Posted December 19, 2007 Really? For multiple I've been informed no closing tag is required. Quote Link to comment Share on other sites More sharing options...
redarrow Posted December 19, 2007 Share Posted December 19, 2007 and here a quick example of implode and explode <?php $msg = "Modified Yes Details:"; $x=explode(' ' ,$msg); $x=implode('',$x); echo $x; ?> Quote Link to comment Share on other sites More sharing options...
redarrow Posted December 19, 2007 Share Posted December 19, 2007 you always need a closing tag? ok..... Quote Link to comment Share on other sites More sharing options...
adam291086 Posted December 19, 2007 Share Posted December 19, 2007 You always need closing tag otherwise you are relaying on the browser to predict what you are doing. Some older browser wont do this and therefore mess up your code. It's best practice to end all html tags. Quote Link to comment Share on other sites More sharing options...
NathanS Posted December 19, 2007 Author Share Posted December 19, 2007 ok, I was just getting that from http://www.faqts.com/knowledge_base/view.phtml/aid/578 where they use no closing tags on the options. I shall add one in. Quote Link to comment Share on other sites More sharing options...
redarrow Posted December 19, 2007 Share Posted December 19, 2007 see what we mean by copy and past programmers and ones that study ha.... Quote Link to comment Share on other sites More sharing options...
NathanS Posted December 19, 2007 Author Share Posted December 19, 2007 Indeed. Am doing my best! 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.