title: PHP Random Teacher Generator not working
body: <p>I have a list of teachers &amp; their departments, it's selected randomly in a different part of the code, that all works fine, it genereates a random teacher and the subject they teach (department). <br><br>However, what I want to do is make it so you click one image of a teacher, then it somehow recognises which teacher you selected, then validates whether or not you clicked a teacher with a higher rating (the rating is stored in .TXT).<br><br>
  So for example, <code>Mr Smith</code> teaches <code>Geography</code> and has rating <code>3/10</code>. <code>Mr White</code> teaches <code>History</code> and has rating <code>7/10</code>. You reload the page, and both of those teachers come up, you have to pick who you think has a higher rating, and if you're right, you go to <code>correct.php</code>, if you're wrong you go to <code>incorect.php</code>
  <br>Here's the code. (I can't use $_GET[] btw because when I do, it reloads the page)
  </p>
  
  Who's got a higher rating?</p>
  
  <p><br></p>
  
  <pre><code>&lt;div class="text-1"&gt;&lt;?php echo "Name: " . $teacher1 . "&lt;br&gt;" . "Department: " . $teacher1department . "&lt;br&gt;" . "Rating: " . $teacher1rating;?&gt;&lt;/div&gt;&lt;/br&gt;
  &lt;div class="text-2"&gt;&lt;br&gt;&lt;?php echo "Name: " . $teacher2 . "&lt;br&gt;" . "Department: " . $teacher2department . "&lt;br&gt;" . "Rating: " . $teacher1rating;?&gt;&lt;/div&gt;&lt;/br&gt;
  
  &lt;a href="?selected=2"&gt;&lt;img src="icon.png" onclick="rating()" class="icon 2"&gt;&lt;/a&gt;&lt;br&gt;
  
  &lt;?php
      function rating() {
          /* Tells you who got the higher rating */
          if($teacher1rating &gt; $teacher2rating) {
              $higherRating = $teacher1; 
          }
          if($teacher1rating &lt; $teacher2rating) {
              $higherRating = $teacher2;
          }
      if (isset($_GET['selected'])) {
          if($_GET['selected'] == $higherRating) {
              header( 'Location: correct.php?teacher=' . $teacher1 );
          }
          if($_GET['selected'] != $higherRating) {
              header( 'Location: incorrect.php?teacher=' . $teacher2);
          }
      }
  ?&gt;
  </code></pre>
  
  <p>Live version at <a href="http://hughchalmers.com/stackoverflow" rel="nofollow noreferrer">http://hughchalmers.com/stackoverflow</a>. When I release it, of course the rating won't be publically displayed</p>