foreach + array + multiple checkboxes inside class [solved]
Posted: Fri Apr 28, 2006 2:15 pm
Hey Everybody, it's been a while and I'm a little rusty.
So I've got a form with multiple checkboxes, with the name value assigned as name="food[]"
Following the checkbox tutorial, I was able to split it up into the foreach section as suggested.
The only problem, is I'm using a php mail class, and am having trouple displaying the array into the body of the email properly.
Example of html form code:
And for the php/mail class:
And my error message is
Parse error: parse error, unexpected T_FOREACH in....
So I know I'm doing something wrong with the syntax in that line, (It's got to be that curly bracket), perhaps something with echoing? As always, any advice/hints/help is much appreciated. Hope everyone is well.
j
So I've got a form with multiple checkboxes, with the name value assigned as name="food[]"
Following the checkbox tutorial, I was able to split it up into the foreach section as suggested.
The only problem, is I'm using a php mail class, and am having trouple displaying the array into the body of the email properly.
Example of html form code:
Code: Select all
// blah blah
<input type="checkbox" name="food[]" value="meatballs" />
// blah blahAnd for the php/mail class:
Code: Select all
$mail->Body = "hello, " foreach ($_POST['food'] as $food){ echo $food." is what you selected for your favorite food";}Parse error: parse error, unexpected T_FOREACH in....
So I know I'm doing something wrong with the syntax in that line, (It's got to be that curly bracket), perhaps something with echoing? As always, any advice/hints/help is much appreciated. Hope everyone is well.
j