Login   Register  
PHP Classes
elePHPant
Icontem

File: Examples.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Duncan Gough  >  Scoreboard  >  Examples.php  >  Download  
File: Examples.php
Role: Example script
Content type: text/plain
Description: Scoreboard examples
Class: Scoreboard
Managing game score information in a database
Author: By
Last change:
Date: 10 years ago
Size: 1,624 bytes
 

Contents

Class file image Download
<?

/*
 * 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>";

?>