Hi
I have an update information form, the data is passed into the form fields based on an entry in a database. One of the fields - $animals - in the database accepts an array from the ticked checkboxes of anim[]. On update form I use an implode statement to join the ticked checkbox values together, so that the data is stored in the field "animals" as Cat, Dog and so on.
What I am trying to do is when I call the update form, I want the checkboxes whose values are stored in $animals to be CHECKED.
I have tried using the explode statement, and then a while loop, followed by a switch statement, but it ticks all of the boxes, instead of just the boxes whose data is stored in the $animals field.
This is the code I am using:
$newAnimals = explode(",", "$animals");
while (list($IndexValue, $animals) = each($newAnimals))
{
switch ($operation)
{
case "Cat":
$select = "CHECKED";
case "Dog":
$select = "CHECKED";
case "Rabbit":
$select = "CHECKED";
break;
}
}
echo "
<INPUT TYPE="checkbox" NAME="anim[]" VALUE="Cat" $select1>Cat
<INPUT TYPE="checkbox" NAME="anim[]" VALUE="Dog" $select2>Dog
<INPUT TYPE="checkbox" NAME="anim[]" VALUE="Rabbit" $select3>Rabbit
";
Can anyone help me with what I am doing wrong?