如何在复选框中发送动态值

Good morning . i have created one form to admin to create some user with some permission and i am storing those permission in database using HTML check boxes.and that code is bellow

<label class="q" for="q1">Permission:</label><br>
 <div style="padding-left:170px;">
 <input name="q1[]" type="checkbox" value="1">Student Management<br>
  <input name="q1[]" type="checkbox" value="2">Department Management<br>
 <input name="q1[]" type="checkbox" value="3">Course Management<br>
 <input name="q1[]" type="checkbox" value="4">Transcript Management<br>
  <input name="q1[]" type="checkbox" value="5">Qr Code Printing<br>
  <input name="q1[]" type="checkbox" value="6">Settings<br>
  <input name="q1[]" type="checkbox" value="7">Upload Scaned Certificate<br>
  </div>
 /*php action page*/
   if(isset($_POST['submit']))
         { 
              $q1=implode(',', $_POST['q1']);


                 $qry="INSERT INTO user (permission)

                      VALUES (,'$q1')";

           }

And the permission is storing successfully ,but the problem is while trying to edit the permission i am not able to store the default value which is all ready stored in database . the code is

           /*getting data from data base*/
           if ($result) {
          while ( $row = mysql_fetch_array($result) ) { 
               $q1= $row['permission'];
           }
           }

        /* form for edit permission*/
       print"<label class=\"q\" for=\"q1\" >Permission:</label><br>";
       print"<div style=\"padding-left:170px;\">";

       print"<input name=\"q1[]\" type=\"checkbox\" value=\"1\">Student Management<br>";
       print"<input name=\"q1[]\" type=\"checkbox\" value=\"2\">Department Management<br>";
       print"<input name=\"q1[]\" type=\"checkbox\" value=\"3\">Course Management<br>";
       print"<input name=\"q1[]\" type=\"checkbox\" value=\"4\">Transcript Management<br>";
       print"<input name=\"q1[]\" type=\"checkbox\" value=\"5\">Qr Code Printing<br>";
       print"<input name=\"q1[]\" type=\"checkbox\" value=\"6\">Settings<br>";
       print"<input name=\"q1[]\" type=\"checkbox\" value=\"7\">Upload Scaned Certificate<br>";
       print"</div>";
       print"</li>";

how to set my default database value for check box that one i need to store in database , please give me some hint i am new to Php, thanks in advance

  if ($result) {
          while ( $row = mysql_fetch_array($result) ) { 
               $q1= $row['permission'];
           }
   }

   $perm=explode(',',$q1);//it's return all value in array 



//now check the all the value in array or not? 
//if value available in arrar than check the checkbox  
//in_array(value, array)? 'checked="checked"':''



    $permission=array('Student Management','Department Management','Course Management','Transcript Management','Qr Code Printing','Settings','Upload Scaned Certificate');
  $num=7;//number of permission

  for($i=0;$i<$num;$i++)
  {
      if(in_array(($i+1), $perm))
      {
           print "<input name=\"q1[]\" type=\"checkbox\" value=\"".($i+1)."\" checked=\"checked\" >".$permission[$i]."<br>";
      }
     else
     {
           print "<input name=\"q1[]\" type=\"checkbox\" value=\"".($i+1)."\" >".$permission[$i]."<br>";
     }
  }

Try with the below code,

 while ( $row = mysql_fetch_array($result) ) { 
           $q1= $row['permission'];
           $checkboxlabel=$row['title'];
  print"<input name=\"q1[]\" type=\"checkbox\" value=\".$q1.\">".$checkboxlabel."<br>";
 }

for a very basic approach (without error checking) you can just do:

/*getting data from data base
           if ($result) {
          while ( $row = mysql_fetch_array($result) ) { 
               $q1= $row['permission'];
           }
           }

        /* form for edit permission
       print"<label class=\"q\" for=\"q1\" value =\"$q1\">Permission:</label><br>";
       print"<div style=\"padding-left:170px;\">";

       print"<input name=\"q1[]\" type=\"checkbox\" value=\"$q1[0]\">Student Management<br>";
       print"<input name=\"q1[]\" type=\"checkbox\" value=\"$q1[1]\">Department Management<br>";
       print"<input name=\"q1[]\" type=\"checkbox\" value=\"$q1[2]\">Course Management<br>";
       print"<input name=\"q1[]\" type=\"checkbox\" value=\"$q1[3]\">Transcript Management<br>";
       print"<input name=\"q1[]\" type=\"checkbox\" value=\"$q1[4]\">Qr Code Printing<br>";
       print"<input name=\"q1[]\" type=\"checkbox\" value=\"$q1[5]\">Settings<br>";
       print"<input name=\"q1[]\" type=\"checkbox\" value=\"$q1[6]\">Upload Scaned Certificate<br>";
       print"</div>";
       print"</li>";

You might want to make sure the values actually exist though.