Welcome Guest, Not a member yet? Register   Sign In
multiple checkboxes
#2

The problem you are describing is probably here:

PHP Code:
if ($db_key array_search($val$services)) 

If $val is the first entry in $services, the key is probably 0, so your if() statement evaluates to false and moves on to the else clause. The manual entry for array_search() includes a warning about this behavior: http://php.net/manual/en/function.array-...turnvalues

So, you could rewrite this as:

PHP Code:
$db_key array_search($val$services);
if (
$db_key !== FALSE

or you could do something like this:

PHP Code:
$db_key array_search($val$services);
?>
<input type='checkbox' name='service[]' value='<?php echo $key?>'<?php echo $db_key === false '' ' checked="checked"'?> /> 

or you could use the form helper's form_checkbox() or set_checkbox() functions.
https://codeigniter.com/userguide2/helpe...elper.html
Reply


Messages In This Thread
multiple checkboxes - by prtk418 - 07-07-2016, 01:56 PM
RE: multiple checkboxes - by mwhitney - 07-08-2016, 07:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB