Cam
Cam

Reputation: 970

PHP / JS - Leader board for game

I'm creating a leader board (a small results table) for a Javascript game i've created which displays the top three 3 scores, the score will be a string e.g - '100'.

How would i insert/retrieve the score data into and from my DB? the game sits in a wordpress site, are there wordpress php functions that would help me insert/query this data.

thanks in advance, Cam

Upvotes: 2

Views: 1542

Answers (2)

austinhallock
austinhallock

Reputation: 126

An easier solution would be to use Clay.io - we've spent a lot of time working on our API, of which leaderboards is a feature.

Have a look at the Developer Info page, and docs for HTML5 leaderboards.

The code ends up being as simple as: ( new Clay.Leaderboard( { id: 1 } ) ).show();

Disclaimer: I am a co-founder of Clay.io

Upvotes: 0

Laurence Burke
Laurence Burke

Reputation: 2358

Ajax would be the way to do this you can create a simple php file that you can set the high scores from when the game ends and retrieve them also with another one.

more on jquery ajax http://api.jquery.com/jQuery.ajax/

an example of php with jquery ajax http://www.php4every1.com/tutorials/jquery-ajax-tutorial/

Upvotes: 2

Related Questions