Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mail() help sending multiple selections

Status
Not open for further replies.

dadms

Technical User
Mar 8, 2003
67
US
I am using a form where multiple cities can be selected with the following code:
EXAMPLE
<select name='local[]' multiple>
<option value="ATLANTA">ATLANTA</option>
<option value="CONYERS">CONYERS</option>
<option value="CHICO">CHICO</option>
</select>

I am able to display the selection on SUBMIT with the following code:
<?php
$i=0;
while($i<count ($local)) {
print $local[$i];
print ", ";
$i=$i+1;
}
?>

How can I get the multiple selected cities to display in an email? The form emails fine with all the other variables ie name, phone numbers, etc. I just dont know what variable to use to display the selected city information in the email.

Please help.
 
There are several ways. I recommend:
Concatenation of the array values using implode()
Code:
$cities = implode(", ",$_POST['local']);
 
Please excuse me for my ignorance with the implode command since I have not used it before. However would the format be to use

<?php
$i=0;
while($i<count ($local)) {
print $local[$i];
print ", ";
$i=$i+1;
}
?>

firt and then set the new variable

$cities = implode(", ",$_POST['local']);
 
You don't need a loop if you implode. Imploding puts all parts of the array into one string.
Code:
print implode(', ',$local);
The above line should suffice to print out a comma separated list of all checked items.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top