> This is what the $_POST['selectedcontactlist'] looks like
> 
> 121,17,97,123,243,52,138,114,172,170,64,49,60,256,176,244,201,42,95,4,

First question is why do you need to pass it through like that?

> it is not coming across as an array so the foreach is throwing an error

I assume it always has a ',' in it if you only choose one box.

if (strpos($_POST['selectedcontactlist'], ',') === false) {
  // no boxes were selected - or at least there is no comma.
  die();
}

// turn it into an array
$selected_contact_lists = explode(',', $_POST['selectedcontactlist']);


> This number are selected in a checkbox and passed with a javascript to
> the script should I be converting them to an array in the javascript.

No need to do that either, just make the form variable an array:

<input type="checkbox" name="selectedcontactlist[]" value="X">

The [] turns it into an array which php can then process automatically
as an array.


You can check that some checkboxes are ticked using an idea similar to this:

http://homepage.ntlworld.com/kayseycarvey/jss3p8.html

Though I'd just either set a flag or counter instead of a message when
you find one that is checked.

If you're just checking that any are checked, as soon as you find one,
return true out of the function.

-- 
Postgresql & php tutorials
http://www.designmagick.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to