title: Query inside while loop of another query
body: <p>My code here doesn't works. I don't know why. I followed other posts solutions regarding this. Could you please help me find the error on this? The inside query has error and not updating at all. Thank you so much.</p>
  
  <p>The pef_table has multiple record based on the single record from the std_booking table. And I'm trying to concat the column I wanted to insert(update query) in the std_booking table based on 'cs' on the first query.</p>
  
  <pre><code>$result1 = mysqli_query($conn, "SELECT cs FROM std_booking");
  if($result1-&gt;num_rows&gt;0){
      while($row1 = $result1-&gt;fetch_assoc()){
          $cs = $row1['cs'];
  
          $pefDocConcat = "";
          $pefRemConcat = "";
  
          /*updating std_booking PEFs*/   
          $result2 = mysqli_query($conn, "SELECT pefDoc, pefRemarks FROM pef_temp WHERE con_stckr = '$cs'");
  
          if($result2-&gt;num_rows&gt;0){
              while($row2 = $result2-&gt;fetch_assoc()){
                  $pefDoc = $row2['pefDoc'];
                  $pefRemarks = $row2['pefRemarks'];
  
                  $pefDocConcat .= $pefDoc . "|";
                  $pefRemConcat .= $pefRemarks . "|";
              }
  
              mysqli_query($conn, "UPDATE INTO std_booking SET std_pefDocs = '".$pefDocConcat."', std_pefRemarks = '".$pefRemConcat."' WHERE cs = '$cs'");
          }
      }
  }
  </code></pre>