Forum Moderators: coopster

Message Too Old, No Replies

how to edit the form containing check boxes

         

ferhanz

12:25 pm on Jul 26, 2005 (gmt 0)

10+ Year Member



I have a form in which user selects different options from check boxes and those values are saved in the database in seperate fileds ..e.g. if he/she select sports, TV, magazine from a list of 10 options then all three options will be inserted seperately in there respective fields. What if i want user to later edit these options ..should i first delete all the previous options and then insert the new ones or is there ay other way?/

Farhan

omoutop

12:34 pm on Jul 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



HI!

Firslty..when you create the edit panel u gonna use a similar form (similar with the one u need to post variables)...however, in that form u will check if the check box is checked (if there is a value in the field in the table)...so a bit of php is needed...
example:
<?
if ($TV == '1')
{?>
<input type="checkbox" name="TV" value="Y" checked>
TV
<? }
else
{
?>
<input type="checkbox" name="TV" value="Y">
TV
<?
}
?>

afterwards, when the user posts the form then u delete the field and udate it afterwards...I empty it first and the update...

example:
$TV = HTTP_POST_VARS['TV'];

$query33 = "update Hotels set TV='' where ID='$ID'";
$result33 = mysql_query($query33);
$query34 = "update Hotels set TV='$TV' where ID='$ID'";
$result34 = mysql_query($query34);
u need some error checking code after to check if results are ok...
thats the way i handle check boxes updatesss
...hope the best ;-)