title: Display users rank in leaderboard table php mysql?
body: <p>I have created a quiz page that stores a logged in users quiz result to a leaderboard.</p>
  
  <p>I have a table called members with the columns user and quiz_score. I have a leaderboard printing out depending on the result of a quiz taken by the logged in user. I am having problems displaying the specific users position in the leaderboard on their profile page. I would also like to attach a medal (e.g jpeg image) if they are in the top three.
  here is the code I have so far for the leaderboard:   </p>
  
  <pre><code>    &lt;?php
  
  require_once 'header.php';
      // Send variables for the MySQL database class.
      $database = mysql_connect('localhost', 'root', 'password') or die('Could not connect: ' . mysql_error());
      mysql_select_db('robinsnest') or die('Could not select database');
  
      $query = "SELECT * FROM `members` ORDER by `quiz_score` DESC LIMIT 10";
      $result = mysql_query($query) or die('Query failed: ' . mysql_error());
  
      $num_results = mysql_num_rows($result);  
  
      echo '&lt;div class="container marketing"&gt;
          &lt;div class="col-xs-12 col-sm-8 col-md-6 col-sm-offset-2 col-md-offset-3"&gt;
            &lt;table class="gradienttable"&gt;
    &lt;tr&gt;
      &lt;th&gt;Position&lt;/th&gt;
      &lt;th&gt;User Name&lt;/th&gt;      
      &lt;th&gt;Score&lt;/th&gt;
  
    &lt;/tr&gt;';
  
      for($i = 1; $i &lt;= $num_results; $i++)
      {
           $row = mysql_fetch_array($result);
  
           echo "&lt;tr&gt;
      &lt;td&gt;".$i."&lt;/td&gt;
      &lt;td&gt;".$row['user']."&lt;/td&gt;       
      &lt;td&gt;".$row['quiz_score']."&lt;/td&gt;
  
    &lt;/tr&gt;";
      }
  
  echo "&lt;/table&gt;
          &lt;/div&gt;
              &lt;/div&gt;";
  echo"&lt;hr class='featurette-divider'&gt;";
      echo '            &lt;footer&gt;
                  &lt;p class="pull-right"&gt;&lt;a href="#"&gt;Back to top&lt;/a&gt;&lt;/p&gt;
                  &lt;p&gt;2015 Students-NCI, &amp;middot; &lt;a href="#"&gt;Privacy&lt;/a&gt; &amp;middot; &lt;a href="#"&gt;Terms&lt;/a&gt;&lt;/p&gt;
              &lt;/footer&gt;';
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And the code I have for printing out the user score so far:</p>
  
  <pre><code>    &lt;?php
  require_once 'header.php';
  $database = mysql_connect('localhost', 'root', 'password') or die('Could not connect: ' . mysql_error());
      mysql_select_db('robinsnest') or die('Could not select database');
  
      $query = "SELECT  user, quiz_score, FIND_IN_SET( quiz_score, (    
  SELECT GROUP_CONCAT( quiz_score
  ORDER BY quiz_score DESC ) 
  FROM members )
  ) AS rank
  FROM members
  WHERE user =  '$user';";
      $result = mysql_query($query) or die('Query failed: ' . mysql_error());
  
      $num_results = mysql_num_rows($result);  
  
       echo "&lt;p&gt;".$query."&lt;/p&gt;";
  echo"&lt;hr class='featurette-divider'&gt;";
  
      echo '            &lt;footer&gt;
                  &lt;p class="pull-right"&gt;&lt;a href="#"&gt;Back to top&lt;/a&gt;&lt;/p&gt;
                  &lt;p&gt;2015 Students-NCI, &amp;middot; &lt;a href="#"&gt;Privacy&lt;/a&gt; &amp;middot; &lt;a href="#"&gt;Terms&lt;/a&gt;&lt;/p&gt;
              &lt;/footer&gt;';
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Is not printing out the position of the logged in user just the string of the sql query. I have tried out a few different things but have had no success.</p>
  
  <p>Any help would be greatly appreciated.</p>