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
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/
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