Advertisement
Guest User

Online PS2 Outfit Member pull from census.soe.com

a guest
Oct 31st, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.25 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>PS2 Battlefield Intel Presents:</head>
  4. <style>
  5. body {background-color : #212224; color : #CFCFCF; font-family : Arial; font-size: 13px;}
  6. p {color : #CFCFCF;}
  7. a:link {color: #6ea331; text-decoration: none;}
  8. a:visited {color : #6ea331; text-decoration: none;}
  9. a:hover {color : #ffffff; text-decoration: underline;}
  10. a:active {color : #6ea331;}
  11. table {width:80%;}
  12. table, th, td {
  13.     border: 1px solid #CFCFCF;
  14.     border-collapse: collapse;
  15. }
  16. </style>
  17. <body>
  18. <p>NOQR Members Online</p>
  19.  
  20.  
  21. <div>
  22. <?php  
  23. //Database Connection
  24. require ('db.php');
  25.  
  26. //Clear old data
  27. mysql_query("TRUNCATE TABLE `test`.`outfit_member_list`");
  28.  
  29. //Grab data from API
  30. $json = file_get_contents('http://census.soe.com/s:tdavis25/get/ps2:v2/outfit_member/?c:resolve=online_status&c:resolve=character_name&outfit_id=37514290234416173&c:limit=500');
  31. $array = json_decode($json,true);
  32. array_pop($array); //removes last row with rowcount
  33.  
  34. //insert data into DB
  35. foreach($array as $table) {
  36.     foreach($table as $row){
  37.             mysql_query("INSERT INTO `test`.`outfit_member_list` (character_id, member_since, member_since_date, outfit_id, rank, rank_ordinal, online_status, char_name)
  38.             VALUES ('".$row['character_id']."',
  39.             '".$row['member_since']."',
  40.             '".$row['member_since_date']."',
  41.             '".$row['outfit_id']."',
  42.             '".$row['rank']."',
  43.             '".$row['rank_ordinal']."',
  44.             '".$row['online_status']."',
  45.             '".$row['character']['name']['first']."')");
  46.     }
  47.  }
  48.  
  49.  //write table to browser
  50. echo "<table border='1'>
  51. <tr>
  52. <th>Name</th>
  53. <th>Rank</th>
  54. </tr>";
  55.  
  56. //call data from DB
  57. $online = mysql_query("select char_name, rank from outfit_member_list where online_status = 1");
  58.  
  59. //Check for records returned
  60. if (count($online) < 1) {
  61.     echo "<tr><td>No members online</td></tr>";
  62. } else {
  63.     //write values to table
  64.     while($new_row = mysql_fetch_array($online)) {
  65.  
  66.       echo "<tr>";
  67.       echo "<td>" . $new_row['char_name'] . "</td>";
  68.       echo "<td>" . $new_row['rank'] . "</td>";
  69.       echo "</tr>";
  70.       //echo "";  
  71.     }
  72. }
  73. echo "</table>";
  74. //database connection close
  75. mysql_close($link);
  76.  
  77. ?>
  78. </div>
  79. <br>
  80. <footer color : #ffffff; align : center;>Powered by No Quarter Gaming - <a href='http://www.noqr.org'>Join Us</a></footer>
  81.  
  82. </body>
  83. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement