We are using an api to retrieve data from MySQL database and turning it into a json file type. What would be the best way to get that data into an HTML table.
This is the api: https://nauticmc.com/dev/top.php?type=kills&start=0&end=9
Depending on what you change the type to it will change ascending order of the data I.E Kills will display the heights amount of kills first.
$(document).ready(function () {
var json = [{"uuid":"ba6df9ff-84fa-464b-a231-d36782a7fdba","username":"zFrost87","kills":"19","deaths":"6","broken":"34","placed":"34","fish":"15","onlinetime":"9493","mobskilled":"6","crops":"1"},{"uuid":"b07762f3-38a4-45b7-9f21-6147704aee4b","username":"frechette456","kills":"3","deaths":"11","broken":"33","placed":"61","fish":"0","onlinetime":"1251","mobskilled":"1","crops":"7"},{"uuid":"83af0a86-7c09-4c32-8fa5-65db3c50b4cf","username":"MineManFrost","kills":"1","deaths":"2","broken":"16","placed":"1","fish":"0","onlinetime":"238","mobskilled":"0","crops":"0"},{"uuid":"71cb5612-d586-4390-ad78-05d295d6d2bd","username":"Nikolassparrow","kills":"0","deaths":"2","broken":"1","placed":"2","fish":"0","onlinetime":"30","mobskilled":"0","crops":"0"},{"uuid":"c34f51b5-8f2a-4e08-8b83-99d5faf21ea9","username":"SetupS1CK","kills":"0","deaths":"0","broken":"0","placed":"0","fish":"0","onlinetime":"81","mobskilled":"0","crops":"0"},{"uuid":"80212863-9466-4a4b-852e-5812e77d075b","username":"PickCottonNig","kills":"0","deaths":"0","broken":"0","placed":"0","fish":"0","onlinetime":"835","mobskilled":"0","crops":"0"},{"uuid":"a64de20f-91e7-4bb0-80db-4f7f1614d693","username":"OstenGaming","kills":"0","deaths":"0","broken":"1","placed":"0","fish":"0","onlinetime":"213","mobskilled":"0","crops":"0"},{"uuid":"25c60209-9fd4-42b8-a2b7-d78e01c0b3ae","username":"OpTc","kills":"0","deaths":"0","broken":"0","placed":"0","fish":"0","onlinetime":"9","mobskilled":"0","crops":"0"},{"uuid":"3a1dc4c7-e9ec-425e-ad50-54ae37c5f1a7","username":"AutoDolphin","kills":"0","deaths":"11","broken":"20","placed":"1","fish":"0","onlinetime":"444","mobskilled":"0","crops":"0"}];
var tr;
for (var i = 0; i < json.length; i++) {
tr = $('<tr/>');
tr.append("<td>" + json[i].username + "</td>");
tr.append("<td>" + json[i].kills + "</td>");
tr.append("<td>" + json[i].deaths + "</td>");
tr.append("<td>" + json[i].broken + "</td>");
tr.append("<td>" + json[i].placed + "</td>");
tr.append("<td>" + json[i].fish + "</td>");
tr.append("<td>" + json[i].onlinetime + "</td>");
tr.append("<td>" + json[i].mobskilled + "</td>");
tr.append("<td>" + json[i].crops + "</td>");
$('table').append(tr);
}
});
I am using Local JSON for now because Ajax does not allow access cross domain but I would parse it into a var to get it.
I also want people to be able to see what data is on top by corresponding arrows in each column I tried to use datatables.js but that did not work so well
This is just the table without any js or json
https://strixdesigns.com/Stats1/ < I want the arrows to work like this