Example PHP File

Required:

  • PHP 5.3
  • MySQL (pretty obvious, the plugin requires it anyway)
  • php-mysqli libraries

To find out if your webserver has the php-mysqli library, create up a simple php page such as:

<?php
  echo phpinfo();
?>

save it as test.php and then view it in your web browser: eg: http://www.example.com/test.php

scroll down or do a search for 'mysqli'

Live player listing code:

<?php
  $mysql = new mysqli("localhost", "root", "", "db");

  $sqlOnlineList = "SELECT * FROM online_players";
  $result = $mysql->query($sqlOnlineList);
?>

<html>
  <head>
    <title>My Games Live players listing</title>
  </head>

  <body>
    <h3>Live Player Listing</h3>

    <table width="100%">
      <thead>
        <tr>
          <td width="20%">Player</td>
          <td width="20%">World</td>
          <td width="60%">On Since</td>
        </tr>
      </thead>
      <tfoot><tr><td colspan="3"></td></tr></tfoot>
      <tbody>
        <?php while($OnlineName = $result->fetch_object()): ?>
            <tr>
              <td><?php echo $OnlineName->player; ?></td>
              <td><?php echo $OnlineName->current_world; ?></td>
              <td><?php echo date("F j, Y, g:i a", $OnlineName->logon_time); ?></td>
            </tr>
        <?php endwhile; ?>
      </tbody>
    </table>
  </body>
</html>

Comments

  • To post a comment, please or register a new account.
Posts Quoted:
Reply
Clear All Quotes