I am 4 months new to PHP! So please be gentle with me. : )
I have an input form that contains check-boxes(it works and posts array to database correctly!) I have an update form that contains the same check-boxes (it updates and posts array to database correctly BUT IT DOESN'T CORRECTLY DISPLAY database info in the checkboxes!)
The Problem is: I cannot get the update form to correctly display "the check-box array" from the database" It only displays the LAST unit in each array!?!?!?!?!?
Here is my php code to pull the array from the database in a while loop (while loop works perfect and I can echo to the top of the page correctly but I want it in my html form below the php code in the HTML):
...
$childarr = explode(",", $row["children_pref"]);
for($i=0; $i<sizeof($childarr); $i++) {
$children_pref = mysql_real_escape_string($childarr[$i]); }
I have MANY of these but will just show you one...
This is my html code for the form...
...
<input type="checkbox" name="children_pref[]" value="0" <?php if ($children_pref == "0") { echo "checked"; } ?>>
None<br>
<input type="checkbox" name="children_pref[]" value="1" <?php if ($children_pref == "1") { echo "checked"; } ?>> 1<br>
<input type="checkbox" name="children_pref[]" value="2" <?php if ($children_pref == "2") { echo "checked"; } ?>> 2<br>
<input type="checkbox" name="children_pref[]" value="3" <?php if ($children_pref == "3") { echo "checked"; } ?>> 3<br>
<input type="checkbox" name="children_pref[]" value="4" <?php if ($children_pref == "4") { echo "checked"; } ?>> 4<br>
<input type="checkbox" name="children_pref[]" value="5" <?php if ($children_pref == "5") { echo "checked"; } ?>> 5<br>
<input type="checkbox" name="children_pref[]" value="6" <?php if ($children_pref == "6") { echo "checked"; } ?>> 6 or more<br>
Any insight would be greatly appreciated.