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>
Thought I'd share this with you. slightly modified from your example code to display based on the active players field status in the table. This is used in a widget on my VB Bulletin Board. I load it in a static HTML widget using an Iframe pointing to this php file. with
(Static HTML Widget) <iframe src="onlineplayers.php" width="100%" frameborder="0"></iframe>
(onlineplayers.php)