title: Change password for a group based on columns of that group
body: <p>I have a table in database where I have different fields like name, email, mobile number, group etc, and a password field, plus other fields which are unrelated to the question.<br>Now, I want to change the password based on whether the mail is provided or the group is provided.<br>The basic <code>sql</code> query for changing my password is:</p>
  
  <pre><code>mysqli_query($con, "UPDATE test_taker SET test_taker_password = CONCAT(test_taker_password, SUBSTRING($select1, '$from1', '$to1')) where test_taker_email = '$mail' OR test_taker_group = '$group'");
  </code></pre>
  
  <p>and I am using this inside as:</p>
  
  <pre><code>$setRec = mysqli_query($con,"select * from test_taker where test_taker_email = '$mail' OR test_taker_group = '$group' ");
  
  while($rec = mysqli_fetch_array($setRec))
  {   
      mysqli_query($con, "UPDATE test_taker SET test_taker_password = CONCAT(test_taker_password, SUBSTRING($select1, '$from1', '$to1')) where test_taker_email = '$mail' OR test_taker_group = '$group'");
      $password=$rec['test_taker_password'];
  }
  </code></pre>
  
  <p>and when I tried with mail, it works perfectly fine, but when I try with group, the while loop replicates for the number of times the number of rows obtained in the setRec.<br> For example, if the password was supposed to be abcd10, ab from name, cd from email, 10 from mobile, and there are two rows in the given group, then password returned is ababcdcd1010.<br><br>Please tell me how to solve this group problem, without harming the mail one.</p>