Re: multiple checkbox storing and retrieving
Posted: Tue Jan 14, 2014 9:59 am
['co_app'] is not a variable. What variable contains the data you've retrieved from the DB?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Oh, I see. This on the same page where the form was initially submitted. In that case, you can use $_POST directly.jaad wrote:I already have $co_app = implode(',', ['co_app']); on the line above. Shouldn't I give the explode function another variable name?
Code: Select all
<input type="checkbox" name="co_app[]" value="roommate" <?= in_array('roommate', $_POST['co_app']) ? 'checked="checked"' : ''; ?>>Code: Select all
Co-Application:
Notice: Undefined index: co_app in C:\xampp\htdocs\lar\settings.php on line 288
Warning: in_array() expects parameter 2 to be array, null given in C:\xampp\htdocs\lar\settings.php on line 288
> Spouse Notice: Undefined index: co_app in C:\xampp\htdocs\lar\settings.php on line 289
Warning: in_array() expects parameter 2 to be array, null given in C:\xampp\htdocs\lar\settings.php on line 289
> Roommate Notice: Undefined index: co_app in C:\xampp\htdocs\lar\settings.php on line 290
Warning: in_array() expects parameter 2 to be array, null given in C:\xampp\htdocs\lar\settings.php on line 290
> None
Code: Select all
<input type="checkbox" name="co_app[]" value="roommate" <?= (array_key_exists('co_app', $_POST) && in_array('roommate', $_POST['co_app'])) ? 'checked="checked"' : ''; ?>>