The way I understand this, $value should pass the array. Am I getting it wrong?
yes its wrong.
$value becomes only whatever is stored in that one slot in the array.
and foreach actually steps through an array, and gives you each item one at a time.
so it needs foreach ( $array as $k=>$v ) { ...code... }
anything with the {} gets executed each time the foreach loop executes, one for each item
$list = array(
'a' => 'apple',
'b' => 'bananna',
'c' => 'cat'
)
foreach ( $list as $key=>$value ) {
MAIL("to","$key","$value","From: name\nX-Priority: 1");
}
executes one time for each item in the list, fills $key and $value with different things each time:
resolves into:
MAIL("to","a","apple","From: name\nX-Priority: 1");
MAIL("to","b","bananna","From: name\nX-Priority: 1");
MAIL("to","c","cat","From: name\nX-Priority: 1");
your code orginal code
foreach($_POST['if_manually_ordered'] as $stuff);
MAIL("to","subject","$stuff","From: name\nX-Priority: 1");
grabs each item off the if_manually_ordered[] array, puts its value into $stuff, and then does absolutely nothing with it.
once its finished running, there is the last item in the list still leftover inside $stuff
then calls MAIL once with the last thing checked.
i think you want
foreach($_POST['if_manually_ordered'] as $stuff)
{
MAIL("to","subject","$stuff","From: name\nX-Priority: 1");
}
this calls MAIL one time for each checkbox, each time with a differnet $stuff.
its a simple problem of brackets... look at my example and see where i use brackets with the FOREACH loop.
make sense?