I have a php code snippet mentioned below
<?php $query = "SELECT * FROM Qualification";
$result = mysqli_query($dbcon,$query);
while($row=mysqli_fetch_array($result)){
?>
<input type='checkbox' value='"<?php $row['Id'] ?> "' name='Qualification[]' /><?php $row['Description'] ?><br>
<?php } ?>
This above Code is used to Display all the qualification from the databases .
Output will be
[] Teacher
[] Engineer
[] Doctor
[] Banker etc..
Now say i have checked 3 checkboxes Teacher,Engineer,Doctor.
foreach($_POST['Qualification'] as $Qualification)
{
$AllQualification .=$Qualification.",";
}
$AllQualification ="1,2,3,"
So i am concatenating the ID of the values into a string and store it in database as 1,2,3,
Now i need to bind the datas again to that checkbox. When i am retriving the selected qualification it gives 1,2,3,
Now How to bind the selectedvalues to the checkbox.
The output i need is teacher,Engineer,Doctor should be checked and banker should be uncheked.
Any help appreciated.
Aucun commentaire:
Enregistrer un commentaire