Charflow

Untitled

Dec 31st, 2013
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.10 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3. include ( '../db_con.php' );
  4. $player = mysql_real_escape_string(addslashes($_GET['player']));
  5.  
  6. if(strlen($player) < 2){
  7.     return;
  8. }
  9.  
  10. $sql = 'SELECT player,sum(kills) as tkills ,sum(death) as tdeath,sum(time) as ttime, sum(points) as total_points , sum(position) as tpos, sum(position = 1) as wins, count(*) as tgames FROM '.$dbprefix.'playerstats WHERE player LIKE \'%'.$player.'%\' GROUP BY player ORDER BY total_points desc LIMIT 500';
  11.  
  12. $result = mysql_query($sql);
  13. echo mysql_error();
  14. $index = ($p * $per_page)+1;
  15. echo '<center><table id="ldr_table"><tr class="lb_tb_hd" align="center"><td>Position</td><td>Player</td><td>Points</td><td>Wins</td><td>Avg Finish</td><td>Kills</td><td>Deaths</td><td>K/D</td><td>Games Played</td><td>Time Ingame</td></tr>';
  16. while($row = mysql_fetch_array($result)){
  17.  
  18.    
  19.  
  20.     echo '<tr class="ldr_alt',($index%2) + 1,'"><td>',getRank($row['player']),'</td>';
  21.  
  22.     echo '<td><a href="index.php?page=player&player=',$row['player'],'">',$row['player'],'</a></td>';
  23.     echo '<td>',$row['total_points'], '</td>';
  24.     echo '<td>',$row['wins'],'</td>';
  25.     echo '<td>',round($row['tpos'] / $row['tgames'], 2),'</td>';
  26.     echo '<td>',$row['tkills'],'</td>';
  27.     echo '<td>',$row['tdeath'],'</td>';
  28.     echo '<td>',round($row['tkills']/$row['tdeath'], 2),'</td>';
  29.     echo '<td>',$row['tgames'],'</td>';
  30.     $hours = round($row['ttime']/ (1000*60*60),0);
  31.     $min = round(($row['ttime']% (1000*60*60)) / (1000*60),0);
  32.     $sec = round((($row['ttime']% (1000*60*60)) % (1000*60)) / 1000,0);
  33.    
  34.  
  35.     echo '<td>',$hours,':',$min,':',(($sec<10)?'0':''),$sec,'</td>';
  36.     echo '</tr>';
  37.  
  38.     $index++;
  39.  
  40. }
  41. echo '</table>';
  42. return;
  43.  
  44. function getRank($rank_search){
  45. include ( '../db_con.php' );
  46.  
  47. $sql_rank = 'SELECT player, sum(points) as total_points FROM '.$dbprefix.'playerstats GROUP BY player ORDER BY total_points desc';
  48.  
  49. $result_rank = mysql_query($sql_rank);
  50. echo mysql_error();
  51.  
  52. $rank = 1;
  53. $finished = false;
  54. $max = 5000;
  55.  
  56. while($rank<=$max AND $row=mysql_fetch_array($result_rank)){
  57.     if($row['player'] == $rank_search){
  58.         $finished = true;
  59.         break;
  60.     }
  61.     $rank++;
  62. }
  63. return $rank;
  64. }
  65.  
  66. ?>
Advertisement
Add Comment
Please, Sign In to add comment