Re: Checking Checkboxes using Arrays
| From: | jimtronic | Date: | Thu, 06 Dec 2001 16:19:06 +0000 |
| Subject: | Re: Checking Checkboxes using Arrays | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-76901@lists.php.net to get a copy of this message | ||
When you perform the test you want to know if the $id is the user's choice and if the user's choice is in the array.
Your code reads differently. You are checking to see if $id is the user's choice OR $id is in the array. which would always check the countries in the array.
if(($id == $register_country_of_origin) || (in_array($id, $european_union))) {try this ...
jimif(($id == $register_country_of_origin) ||(in_array($register_country_of_origin, $european_union))) {
-- Jim Musil --------- Multimedia Programmer Nettmedia ------------- 212-629-0004 jim@nettmedia.com$european_union = array('24', '17', '1', '58', '74', '80','73', '83', '101', '103', '119', '144', '164', '186', '193', '212');print_r($european_union);if(mysql_num_rows($europe_result) > 0) {while(list($id, $country) =mysql_fetch_array($europe_result)) {if(($id == $register_country_of_origin) ||(in_array($id, $european_union))) {echo"\t<TD WIDTH=\"50%\"CLASS=\"pofgreencard\"><INPUT TYPE=\"checkbox\" NAME=\"country_id[]\" VALUE=\"$id\" CHECKED> $country</TD>\n";} else {echo"\t<TD WIDTH=\"50%\"CLASS=\"pofgreencard\"><INPUT TYPE=\"checkbox\" NAME=\"country_id[]\" VALUE=\"$id\"> $country</TD>\n";} }