title: How to insert value of the checkbox array into the database while the cheekboxs value also have been retrieved from the database?
body: <p>I am retrieving the result of the query from the database.I have stored id of the record into the checkbox array.
  I was able to retrieve the data and store into the checkbox array successfully.now i want to insert the value of the checkbox into different table.In below code i have used a for loop to insert data and implode function to retrive array element but when i run this script it didnt show any error but data was not inserted  into the database.
  can anyone please tell me what i am doing wrong? and how can i fix that?  </p>
  
  <pre><code>&lt;?php
  
      $conn = mysqli_connect('localhost:3306', 'root', '', 'mydatabase');
      if($conn -&gt; connect_errno){
          die('coudn\'t connect to the database' . mysqli_connect_error());
      }
      else{
          $query = "select * from simple";
          $result = $conn -&gt; query($query);
              echo '&lt;table border="1px"&gt;&lt;tr&gt;&lt;td&gt;Select&lt;/td&gt;&lt;td&gt;ID&lt;/td&gt;&lt;td&gt;Name&lt;/td&gt;&lt;td&gt;Surname&lt;/td&gt;&lt;/tr&gt;';
              while ($row = $result-&gt;fetch_array(MYSQLI_ASSOC)) {
                  echo '&lt;tr&gt;';
                  echo "&lt;td&gt;&lt;input type=\"checkbox\" name=\"checkbox[]\" id=\"checkbox[]\"  value=\"".$row['id']."\" /&gt;&lt;/td&gt;";                   
                  echo "&lt;td&gt;{$row['id']}&lt;/td&gt; "."&lt;td&gt;{$row['Name']}&lt;/td&gt;"."&lt;td&gt;{$row['Surname']}&lt;/td&gt;";
                  echo '&lt;/tr&gt;';
              }
              echo '&lt;/table&gt;';
              echo "Fetched data successfully\n";
              $limit = count('$checkbox');
              echo $limit;
              for($i=0;!$limit &gt; 0;$i++,$limit--){
                  $res = implode(",", '$checkbox');
                  $q1 = 'insert into joint_data values("'.$i.'","'.$res.'")';
                  if($conn -&gt; query($query) == TRUE){
                          echo "Data Entered successfully\n";
                      }
                  echo $i,$res;
              }
          }
          $result-&gt;free();
      mysqli_close($conn);
    ?&gt;
  </code></pre>