Location: PHPKode > scripts > Scoreboard class > scoreboard-class/Examples.php
<?

/*
 * Scoreboard: Examples
 *
 * The following is a brief list of examples demonstrating
 * how to use the Scoreboard and SQL classes.
 *
 * Distributed under the LGPL license:
 * http://www.gnu.org/licenses/lgpl.html
 *
 * Duncan Gough
 * 3rdSense.com
 *
 * Home  http://www.suttree.com
 * Work  http://www.3rdsense.com
 * Play! http://www.playaholics.com
 */

require_once( "Scoreboard/Scoreboard.php" );

# 1. Submitting a score

$scoreboard = new Scoreboard;

$user_id = 1;
$game_name = "tetris";
$score = 500;

$scoreboard->submit_score( $user_id, $game_name, $score );

# Repeat this a few times to create some dummy data in your
# scores database. Insert dates from this week and also 
# from last week in order for the following examples to work.

# 2. Retrieving a scoreboard for an individual game, this week

$scoreboard = new Scoreboard;

$data = $scoreboard->this_week( $game_name );

print "<pre>";
var_dump( $data->scoreboard );
print "</pre>";

# 2. Retrieving a scoreboard for an individual game, last week

$scoreboard = new Scoreboard;

$data = $scoreboard->last_week( $game_name );

print "<pre>";
var_dump( $data->scoreboard );
print "</pre>";

# 3. Retrieving a scoreboard for a particular user, for this week

$scoreboard = new Scoreboard;

$data = $scoreboard->personal_scoreboard_this_week( $user_id );

print "<pre>";
var_dump( $data->scoreboard );
print "</pre>";

# 4. Retrieving a scoreboard for a particular user, for last week

$scoreboard = new Scoreboard;

$data = $scoreboard->personal_scoreboard_last_week( $user_id );

print "<pre>";
var_dump( $data->scoreboard );
print "</pre>";

?>
Return current item: Scoreboard class