Advertisement
Guest User

Untitled

a guest
Mar 16th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. <?php
  2. $user = 'sa';
  3. $pass = '123';
  4. $host = '10.0.2.15';
  5. $dbname = 'Game3G';
  6. try{
  7. $dbh = new PDO ("mssql:host=$host;dbname=$dbname", "$user", "$pass");
  8. $n=0;
  9. function sorting($next,$table) {
  10. $temp=0;
  11.  
  12. foreach($table as $entry) if($entry['position']==0) if($entry['level']>=$temp['level'] && $entry['exp']>=$temp['exp']) $temp=$entry;
  13. if($temp) {
  14. $table[$temp['id']]['position']=$next;
  15. echo '<tr>
  16. <td width="20px" style="font-size: 10px;">'.$next.'</td><td width="80px" style="font-size: 10px;">'.$temp['character'].'</td><td style="font-size: 10px;">'.$temp['level'].'</td> <td width="30px" style="font-size: 10px; text-align: right;">'.$temp['exp'].'%</td>
  17. </tr>
  18. ';
  19. sorting($next+1,$table);
  20. }
  21. }
  22.  
  23.  
  24. echo '<br> <table width="170" border=0 >';
  25. $i=0;
  26. foreach ($dbh->query('SELECT TBL_CHARACTER.FLD_LEVEL, TBL_CHARACTER.FLD_jOB, TBL_CHARACTER.FLD_CHARACTER, TBL_ABILITY.FLD_MAXEXP, TBL_ABILITY.FLD_EXP from TBL_CHARACTER LEFT JOIN TBL_ABILITY ON(TBL_CHARACTER.FLD_CHARACTER = TBL_ABILITY.FLD_CHARACTER) where TBL_CHARACTER.FLD_LEVEL < 69 and TBL_CHARACTER.FLD_jOB = 2 and TBL_CHARACTER.FLD_DELETED = 0 order by TBL_ABILITY.FLD_EXP + TBL_ABILITY.FLD_LEVEL * TBL_ABILITY.FLD_MAXEXP desc') as $row)
  27. {
  28. $i++;
  29. $table[$i-1]['level']=$row['FLD_LEVEL'];
  30. $table[$i-1]['character']=$row['FLD_CHARACTER'];
  31. $table[$i-1]['exp']=round(($row['FLD_EXP']/$row['FLD_MAXEXP'])*100);
  32. $table[$i-1]['id']=$i-1;
  33. $table[$i-1]['position']=0;
  34.  
  35. $n++;
  36. if($n>=10) break;
  37. };
  38. sorting(1,$table);
  39. echo '</table><br>';
  40. $dbh = null;
  41. }
  42. catch(PDOException $e){
  43. echo 'Statystyki niedostępne.';
  44. }
  45. /*end*/
  46. ?>
  47.  
  48. PHP Notice: Undefined variable: table in C:\Inetpub\wwwroot\tao.php on line 38
  49. PHP Warning: Invalid argument supplied for foreach() in C:\Inetpub\wwwroot\tao.php on line 12
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement