title: I can't understand how the code below continue looping through items in database?
body: <p>I want to check the user login entry data to find if they are existed.<br>
  Imagine we have just 10 records in the database(10 user).<br>
  I know if i want to check user login entry data with data in database, i should use while loop.<br>
  As you see in the code below i used while loop and fetch_assoc method to get each record from database.
  <br><br>
  <strong>the code below works correct!</strong>
  <br><br>
  but I can't understand the work flow of "<strong>if statement</strong>" inside the loop.<br><br></p>
  
  <p>take the first record in database.<br>
  fetch_assoc method fetch the first record from the database to check it with user entry data. then "if statement" check both user data and fetched data with each other. what confuses me is that if data does not match with first record, else statement must return the user to login page. I mean just one row is checked!!<br>
  <strong>-how does it check other records with user entry data!</strong>
  <br>
  <strong>-how does it jump from else statement to while loop!?</strong></p>
  
  <p>could you please explain entire the code in detail.</p>
  
  <pre><code>    $select_query= "select `username`,`pass` from `register`";
      $result= $db_connection-&gt;query($select_query);
  
          while($row= $result-&gt;fetch_assoc()){
              if($row["username"] === $username &amp;&amp; $row["pass"] === $pass){
                  header("location:../account.php");
              }else{
                  header("location:../login.php");
              }
          }
  </code></pre>