<form>
<input type="checkbox" name="vehicle" value="Bike" /> I have a bike<br />
<input type="checkbox" name="vehicle" value="Car" /> I have a car
</form>
These are the few steps you have to do.
1.Fetch the values from database.
2. Covert the values in array as they are stored as string by (,) separated.
3. Then
foreach($values as $val)
{
if($val == Bike )
{
$bikeflag = 1 ;
}
if($val == Car )
{
$carflag = 1 ;
}
}
<form>
<input type="checkbox" name="vehicle" value="Bike" <?php if(isset($bikeflag ) == 1 ){ ?>checked = checked <?php } ?>/> I have a bike<br />
<input type="checkbox" name="vehicle" value="Car" <?php if(isset($carflag) == 1 ){ ?>checked = checked <?php } ?>/> I have a car
</form>
希望这能帮到你