Advertisement
Guest User

Untitled

a guest
Oct 19th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1.  
  2.  
  3. $online = 0; //leave this alone
  4. $horde = 0; //leave this alone
  5. $alliance = 0; //leave this alone
  6. $host = "localhost"; //MySQL host
  7. $user = "root"; //MySQL use
  8. $pass = "ascent"; //MySQL pass
  9. $char_db = "characters"; //database containing the 'characters' table.
  10.  
  11. $con = mysql_connect($host, $user, $pass) or die("Could not connect to MySQL" . mysql_error($con));
  12. mysql_select_db($char_db, $con) or die("Could not select MySQL database" . mysql_error($con));
  13. $query = mysql_query("SELECT * FROM characters WHERE online = '1'", $con);
  14. while($list = mysql_fetch_array($query)){
  15. $online = $online + 1;
  16. if($list['race'] == 2 || $list['race'] == 5 || $list['race'] == 6 || $list['race'] == 8 || $list['race'] == 10){
  17. $horde = $horde + 1;
  18. } else {
  19. $alliance = $alliance + 1;
  20. }
  21. }
  22. if($online == 0){
  23. echo "There are no players online";
  24. } else {
  25. echo "There are a total of " . $online . " players online. " . $horde . " are Horde, and " . $alliance . " are Alliance.";
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement