Page 2 of 2

Re: multiple checkbox storing and retrieving

Posted: Tue Jan 14, 2014 9:59 am
by Celauran
['co_app'] is not a variable. What variable contains the data you've retrieved from the DB?

Re: multiple checkbox storing and retrieving

Posted: Tue Jan 14, 2014 12:08 pm
by jaad
the field in the database is called co_app. I was referring to the $co-app in my last post. as for what I am retrieving from the database I am not retrieving anything. I have the error message that I;ve posted in my previous post

Re: multiple checkbox storing and retrieving

Posted: Tue Jan 14, 2014 12:27 pm
by Celauran
jaad wrote:I already have $co_app = implode(',', ['co_app']); on the line above. Shouldn't I give the explode function another variable name?
Oh, I see. This on the same page where the form was initially submitted. In that case, you can use $_POST directly.

Code: Select all

<input type="checkbox" name="co_app[]" value="roommate" <?= in_array('roommate', $_POST['co_app']) ? 'checked="checked"' : ''; ?>>

Re: multiple checkbox storing and retrieving

Posted: Tue Jan 14, 2014 2:59 pm
by jaad
nope.... still the same thing I get the following:

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 

Re: multiple checkbox storing and retrieving

Posted: Tue Jan 14, 2014 3:02 pm
by Celauran

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"' : ''; ?>>

Re: multiple checkbox storing and retrieving

Posted: Tue Jan 14, 2014 3:19 pm
by jaad
well it got rid of the error messages but no values get saved to the database now. none comes back either. I think my explode function() is broken. I wonder if they fix that at the garage at the corner by my place lol. I really thank you for trying man, you are going beyond the call of duty here.