The Leaderboard module
The flow is the same with the Leaderboard module as with the Achievements module. Here is the JavaScript:
function GetLeaderBoard(){ var action='GetLeaderBoard',html='',Username='',Points='',html="<table>"; $.ajax({ dataType: "json", data: {action:action}, url: $AJAXHANDLER, success: function (data){ for (var i = 0; i < data.length; i++) { if (data[i].UserName==''){Username='Anonymous'}else{Username=data[i].UserName}; Points = data[i].Points; html+='<tr><td><a href="#">'+Username +'</a></td><td>'+Points+'</td></tr>'; } html+="</table>"; $("#leaderboardsdiv").append(html); }, error: function (xhr, status, error) { } }); }
Here is the associated PHP function:
function GetLeaderBoard(){ $storedProcedure = "Select distinct UserName,Points from Player order by points desc LIMIT 0,5"; $Leaders = array(); $fetch = mysql_query($storedProcedure); while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) { $row_array...