title: The second query in a nested if else loop doesn't return an exceptions message
body: <p>The code below currently successfully checks a table of values that matches that of the user input      = $upn and returns "No pupil exists." If no values are found.  I now wish to run another check of a different table. The second query is a very similar check to the previous query, apart from checking for a project rather than a pupil.</p>
  
  <p>These two queries are currently organized as you see here. Project query under Pupil query. The     project query doesn't return No Project exists. When the user enters an invalid value.</p>
  
  <p>I think it may be something to do with putting the second query after the while loop of the first query.</p>
  
  <p>Is there a way of getting these two queries to work?</p>
  
  <p>Thank you for your time.</p>
  
  <pre><code>{
  $query = mysql_query("SELECT pupil_forename, pupil_surname FROM pupil WHERE pupil_id = '$upn'");
      $count = mysql_num_rows($query);
      if ($count == 0 ) {
          $output = "No Pupil exists.";     
      } else{        
          while($row = mysql_fetch_array($query)){
              $fname = $row['pupil_forename'];
              $sname = $row['pupil_surname'];
  
      $proquery = mysql_query("SELECT * FROM project WHERE project_code = '$project'");
          $count = mysql_num_rows($proquery);
          if ($count == 0 ) {
              $output = "No Project exists.";
  }
  </code></pre>