frainbreeze
Technical User
hello
i have a mysql db that has 1 column for descriptions of images (i.e. people, signs, cat, dog). to input them into the db, i've used a form where all the checkboxes are imploded into an array and then stored as \n separated values.
when the user selects a record/image to edit, i would like the description checkboxes to automatically be checked, that way the user can uncheck (if the description no longer applies) or check more description boxes to update the record. at present, the user sees a textfield which displays the descriptions for that record, and has to manually re-check all the description boxes that already apply, as well as any additional ones they wish to add.
in so far i've managed to explode the words in the description column into an array, and loop through the array and have it return a value of checked or not.
and the form checkbox looks like this:
but i cant seem to have $checkval reset for the next checkbox...i.e. if $checkval is true for the 1st box, then it stays true for the entire form.. is it something to do with my loop structure?
thanks for any help
annie
i have a mysql db that has 1 column for descriptions of images (i.e. people, signs, cat, dog). to input them into the db, i've used a form where all the checkboxes are imploded into an array and then stored as \n separated values.
when the user selects a record/image to edit, i would like the description checkboxes to automatically be checked, that way the user can uncheck (if the description no longer applies) or check more description boxes to update the record. at present, the user sees a textfield which displays the descriptions for that record, and has to manually re-check all the description boxes that already apply, as well as any additional ones they wish to add.
in so far i've managed to explode the words in the description column into an array, and loop through the array and have it return a value of checked or not.
Code:
$checked_values = explode ("\n", $combodesc);
global $checkboxlist;
$checkboxlist = array ("Dog", "Cat", "Signs", "People");
global $checkval;
#Cycle through the db-generated-array
if (isset($checked_values))
{
for($i=0; $i < count($checked_values); $i++)
{
$temp = $checked_values[$i];
if (in_array ($temp, $checkboxlist))
{
$checkval = " checked ";
}
else
{
echo " ";
}
}
}
and the form checkbox looks like this:
Code:
<input type="checkbox" name="desc[]" value="People" <? echo $checkval; ?> >People
<br>
<input type="checkbox" name="desc[]" value="Cats" <? echo $checkval; ?> > Cats
but i cant seem to have $checkval reset for the next checkbox...i.e. if $checkval is true for the 1st box, then it stays true for the entire form.. is it something to do with my loop structure?
thanks for any help
annie