Page 1 of 1

array

Posted: Thu May 17, 2007 10:05 pm
by pinehead18
Help me out here guys.

I have a list of users i select with check boxes.
I want to create an array that houses all the users name.

Then i use swift to send an email to all those users emails one at a time.

Help making the array?

Thanks

Posted: Thu May 17, 2007 10:27 pm
by bdlang
That's at least two questions.

Your form field should use an array structured name, e.g.

Code: Select all

<input type="checkbox" name="username[]" value="Jim" />Jim
<input type="checkbox" name="username[]" value="John" />John
...and so on.

The second part is retrieving that data as an array, which in this case (assuming you're using a POST method form, which you should be) will be accessible via $_POST['username'], in this case an array stored within that $_POST index.

Once you receive the POST data, use a foreach() loop on the $_POST['username'] array and send the email to those users, one per iteration.