Advertisement
Guest User

gold

a guest
Sep 11th, 2013
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.08 KB | None | 0 0
  1. <style>
  2. body {
  3.     margin: 0;
  4.     background:#ddd;
  5. }
  6. h2 {
  7.     margin:5px;
  8. }
  9. table {
  10.     border-collapse:collapse;
  11.     background:#333;
  12.     color:#BBB;
  13. }
  14. th {
  15.     border-left:1px solid #000;
  16.     border-right:1px solid #000;
  17.     border-bottom:1px solid #000;
  18.     color:#fe5;
  19. }
  20. #border {
  21.     border-left:1px solid #000;
  22.     border-right:1px solid #000;
  23.     border-bottom:1px solid #000;
  24. }
  25. #border td {
  26.     border-left:1px solid #000;
  27.     border-right:1px solid #000;   
  28. }
  29. </style>
  30. <?php
  31. $host = 'localhost';
  32. $user = 'root';
  33. $pass = '';
  34. $cdb = 'characters';
  35.  
  36. $connect = mysql_connect($host,$user,$pass) or die('Нет подключения к базе данных');
  37. mysql_select_db ($cdb, $connect) or die(mysql_error());
  38. $sql = mysql_query("SET NAMES cp1251");
  39. $sql = mysql_query("SELECT * FROM `characters` ORDER BY `money` DESC LIMIT 100", $connect) or die(mysql_error());
  40. print "<h2 align=\"center\">Топ богачей</h2>
  41. <table cellpadding=\"1\" cellspacing=\"1\" align=\"center\" width=\"800\"><tr>
  42. <th width=\"30\">№</th>
  43. <th>Имя</th>
  44. <th width=\"30\">Лвл</th>
  45. <th width=\"120\">Раса</th>
  46. <th width=\"120\">Класс</th>
  47. <th width=\"100\">Сторона</th>
  48. <th width=\"200\">Денег</th>
  49. </tr></table>";
  50. $id = 1;
  51. while ($result = mysql_fetch_array($sql)){
  52.     $name = $result['name'];
  53.     $level = $result['level'];
  54.     $money = $result['money'];
  55.     $gold = (int)($money / 10000);
  56.     $total = $money - ($gold * 10000);
  57.     $silver = (int)($total / 100);
  58.     $cooper = $total - ($silver * 100);
  59.    
  60.     if ($result['race'] == 1 || $result['race'] == 3 || $result['race'] == 4 || $result['race'] == 7 || $result['race'] == 11){
  61.         $side = 'Альянс';
  62.         $style_side = 'blue';
  63.     }
  64.     else{
  65.         $side = 'Орда';
  66.         $style_side = 'red';
  67.     }
  68.    
  69.     switch ($result['race']){
  70.         case 1: $race = 'Человек';break;    
  71.         case 2: $result['gender'] == 0 ? $race = 'Орк' : $race = 'Орчиха';break;          
  72.         case 3: $race = 'Дворф';break;
  73.         case 4: $result['gender'] == 0 ? $race = 'Ночной эльф' : $race = 'Ночная эльфийка';break;
  74.         case 5: $result['gender'] == 0 ? $race = 'Отрекшийся' : $race = 'Отрекшаяся';break;
  75.         case 6: $race = 'Таурен';break;
  76.         case 7: $race = 'Гном';break;
  77.         case 8: $result['gender'] == 0 ? $race = 'Тролль' : $race = 'Троллиха';break;
  78.         case 10: $result['gender'] == 0 ? $race = 'Эльф крови' : $race = 'Эльфийка крови';break;
  79.         case 11: $result['gender'] == 0 ? $race = 'Дреней' : $race = 'Дренейка';break;
  80.     }
  81.        
  82.     if ($result['class'] == 1){
  83.         $class = 'Воин';
  84.         $style_class = '#C79C6E';
  85.     }
  86.     if ($result['class'] == 2){
  87.         $class = 'Паладин';
  88.         $style_class = '#F58CBA';
  89.     }
  90.     if ($result['class'] == 3){
  91.         $class = 'Охотник';
  92.         $style_class = '#ABD473';
  93.     }
  94.     if ($result['class'] == 4){
  95.         $class = 'Разбойник';
  96.         $style_class = '#FFF569';
  97.     }
  98.     if ($result['class'] == 5){
  99.         $class = 'Жрец';
  100.         $style_class = '#FFFFFF';
  101.     }
  102.     if ($result['class'] == 6){
  103.         $class = 'Рыцарь смерти';
  104.         $style_class = '#C41F3B';
  105.     }
  106.     if ($result['class'] == 7){
  107.         $class = 'Шаман';
  108.         $style_class = '#0070DE';
  109.     }
  110.     if ($result['class'] == 8){
  111.         $class = 'Маг';
  112.         $style_class = '#69CCF0';
  113.     }
  114.     if ($result['class'] == 9){
  115.         $class = 'Чернокнижник';
  116.         $style_class = '#9482C9';
  117.     }
  118.     if ($result['class'] == 11){
  119.         $class = 'Друид';
  120.         $style_class = '#FF7D0A';
  121.     }
  122.        
  123.     print "<table cellpadding=\"1\" cellspacing=\"1\" align=\"center\" width=\"800\" id=\"border\"><tr>
  124.     <td align=\"center\" width=\"30\">$id</td>
  125.     <td align=\"center\">$name</td>
  126.     <td align=\"center\" width=\"30\">$level</td>
  127.     <td align=\"center\" width=\"120\">$race</td>
  128.     <td align=\"center\" width=\"120\"><font color=\"$style_class\">$class</font></td>
  129.     <td align=\"center\" width=\"100\"><font color=\"$style_side\">$side</font></td>
  130.     <td align=\"center\" width=\"200\"><font color=\"gold\">$gold г.</font> <font color=\"silver\">$silver с.</font> <font color=\"coral\">$cooper м.</font></td>
  131.     </tr></table>";
  132. $id++;
  133. }
  134. mysql_close($connect);
  135. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement