title: retrieve percentile rank using php with joomla 2.5
body: <p>I have been trying to obtain the percentile rank of user based on score.  I can get the result in phpmyadmin - but can't seem to get the code right in php.......</p>
  
  <p>here is what i have so far....</p>
  
  <pre><code>$db=JFactory::getDBO();
  $session =&amp; JFactory::getSession();
  $user =&amp; JFactory::getUser();
  $userId = $user-&gt;id;
  
  $rank = "SELECT rank, cb_cscore,(SELECT 100*(rank / count(*)) FROM  `e72jm_comprofiler`,(SELECT @rownum :=0)r WHERE cb_cscore IS NOT NULL) as percentage FROM (SELECT @rownum := @rownum +1 AS rank, `cb_cscore` , `user_id` FROM `e72jm_comprofiler`,(SELECT @row :=0) r WHERE cb_cscore IS NOT NULL AND user_id = $userId LIMIT 0,1";
  
  $db-&gt;setQuery( $rank );
  $db-&gt;query();
  </code></pre>
  
  <p>but - i keep getting stuck on how to load the results...</p>
  
  <p>meaning how to load the result from the query.....</p>
  
  <p>any help would be greatly appreciated...</p>