title: php checkbox checked on edit page
body: <p>I have 3 tables:</p>
  
  <pre><code>people:
  ------------------------
  peopleID,
  firstname
  
  peopletype:
  ------------------------
  peopletypeID,
  type
  
  peoplepeopletype (junction table):
  ------------------------
  peopleID,
  peopletypeID
  </code></pre>
  
  <p>On the add form everything is fine, but I have problem to display checkboxes checked for the assigned peopletype</p>
  
  <p>Here is my code.</p>
  
  <p>Retrieve data from peoplepeopletype table :</p>
  
  <pre><code>/*PEOPLE TYPE ************* */
  
      $stmt = $conn-&gt;prepare("SELECT * FROM peoplepeopletype WHERE peopleID=?");
  
  
      // set parameters and execute
      if ( !$stmt ) { echo "error"; }
      else if ( !$stmt-&gt;bind_param('i', $_GET['peopleID']) ) { echo "error";}
      else if ( !$stmt-&gt;execute() ) { echo "error"; }
    else {
        $result = $stmt-&gt;get_result();
  
        while($row = $result-&gt;fetch_assoc()) {
            $peopletypeIDfromdb = $row ['peopletypeID'];
            echo $peopletypeIDfromdb; /*echo only for test purposes, but I don't know how to use this in the form */
        }  
    } /* end else */
  </code></pre>
  
  <p>Display checkboxes :</p>
  
  <pre><code> &lt;?php /*retrieve peopletype from db */     
   $sql = "SELECT * from peopletype";
  $result = $conn-&gt;query($sql);
  
  while($row = $result-&gt;fetch_assoc()) { 
      echo '&lt;input required="required" type="checkbox" name="peopletypeID[]" value="' . $row["peopletypeID"] . '"'; 
      if  ($peopletypeIDfromdb = $row["peopletypeID"]) { /*problem is probably here*/
                 echo 'checked';
              }
      echo '&gt;' . $row["type"];
  
  }
                ?&gt;
  </code></pre>
  
  <p>Thanks for your help!</p>