Forum Moderators: coopster
I now have my form output nicely formatted and going to email. However, I can't figure out what I'm doing wrong with the form's multiple select boxes. There are 5 fields on the form that allow multiples.
Here's how I have one setup on the html form:
<select name="emp_badge_sel[]" size="6" multiple="multiple" id="emp_badge_sel">
<option>Bldg 1</option>
<option>Bldg 2</option>
<option>Bldg 3</option>
<option>24 x 7 (COO App)</option>
<option>Weekend (COO App)</option>
<option>Conference Rms</option>
</select>
And here is the portion of the script:
<tr>
<td width=13>Badges:".$_POST['emp_badge_sel']."</td>
</tr>
When that goes thru my script and comes out in the formatted email, what I get is Badges:Array
Ok, so I changed the script to this: <td width=13>Badges:"$my_array[.$POST[emp_badge_sel']]."</td>
What I get then is a "parse error, unexpected T_VARIABLE" on the first line where I put $my_array
What am I missing here?
TIA :)
Do I put that looping code at the end or right in there where the $my_array[.$_post['select name']] is?
Sorry, I'm a complete newcomer to PHP and trying to pick it up on-the-fly. I do the web sites, wear ALL the hats, and now there are 3 more people who have submitted form requests. Picking up a new language on the run isn't my ideal, but its what I'm stuck with for now.
Thanks!
function multiSelect($element){//$element will be the post var that you pass in
$badges = "";
$count = count($_POST[$element]);
for( $i = 0; $i < $count; $i++ ){
$badges .= $_POST[$element][$i]."-";
}
return $badges;
}
You can put that code near the top of your script and to get your result, do something like this where you want the results printed:
<?=multiSelect($_POST["select_1"])?>
<?=multiSelect($_POST["select_2"])?>
...
That's using shorthand. If it gives you an error, try:
<?php print multiSelect($_POST["select_1"]);?>
<?php print multiSelect($_POST["select_2"]);?>
...
The output from my form/script is going into an html-formatted email. Do I still use Print?
This was SO much easier in my Cold Fusion days ;)