Advertisement
s0nic

List

Oct 30th, 2011
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.10 KB | None | 0 0
  1. <?
  2.     $db_host = "localhost";
  3.     $db_name = "";
  4.     $db_user = "";
  5.     $db_pw = "";
  6.     if (isset($db_host, $db_user, $db_pw, $db_name)) {
  7.         mysql_connect($db_host, $db_user, $db_pw) OR die("Cannot connect to your database!");
  8.         mysql_select_db($db_name) OR die("Cannot connect to your database!");
  9.     }
  10. ?>
  11. <?
  12.     echo "<center>";
  13.     echo '<h2>- Stats -</h2><br />';
  14.     $query = "SELECT Name,Kills,Deaths,Tks FROM players ORDER BY `id` LIMIT 50";
  15.     $result = mysql_query("$query")
  16.     or die("Table Content Request Failed: " . mysql_error());
  17.     echo "<div class=\"bodycontent\"><table>\n\t\t\t<tr>\n";
  18.     echo "\t\t\t\t<td style=\"padding-right:15px; margin-right: 120px\"><b><font size='3.5' color=#000>#</font></b></td>\n";
  19.     for ($i = 0; $i < mysql_num_fields($result); $i++)
  20.     {
  21.         echo "\t\t\t\t<td style=\"padding-right:20px; margin-right: 120px\"><b><font size='3.5' color=#000>" . mysql_field_name($result, $i) . "</font></b></td>\n";
  22.     }
  23.     echo "\t\t\t\t<td style=\"padding-right:15px; margin-right: 120px\"><b><font size='3.5' color=#000>Ratio</font></b></td>\n";
  24.     echo "\t\t\t</tr>\n";
  25.     $count = 1;
  26.     while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
  27.     {
  28.         echo "\t\t\t<tr>\n";
  29.         echo "\t\t\t\t<td style=\"padding-right:10px; margin-right: 10px\"><font size='3.5' color=#000>".$count.")</font></td>\n";
  30.         echo "\t\t\t\t<td style=\"padding-right:10px; margin-right: 10px\"><font size='3.5'>".$row['Name']."</font></td>\n";
  31.         echo "\t\t\t\t<td style=\"padding-right:10px; margin-right: 10px\"><font size='3.5' color=#000>".$row['Kills']."</font></td>\n";
  32.         echo "\t\t\t\t<td style=\"padding-right:10px; margin-right: 10px\"><font size='3.5' color=#000>".$row['Deaths']."</font></td>\n";
  33.         echo "\t\t\t\t<td style=\"padding-right:10px; margin-right: 10px\"><font size='3.5' color=#000>".$row['Tks']."</font></td>\n";
  34.         if($row['Kills'] == 0 || $row['Deaths'] == 0) $ratio = "N/A"; else $ratio = round($row['Kills']/$row['Deaths'],2);
  35.         echo "\t\t\t\t<td style=\"padding-right:10px; margin-right: 10px\"><font size='3.5' color=#000>".$ratio."</font></td>\n";
  36.         echo "\t\t\t</tr>\n";
  37.         $count++;
  38.         }
  39.     echo "\n\t\t</table>\n</div>";
  40. ?>
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement