Hi i´m trying to setup a webpage to get some sport results from an API and then put that page as an overlay in a video stream showing the finnish of that sport event.
I use CURL to get the array, store it in $response i can see that i get the answer. Then i try to build the page but i dont get the hang of how i access different parts of the JSON.
<body>
<h1>Sprint DM Sörmland 2020</h1>
<p>Senaste Resultat</p>
<table>
<tr>
<th>Name</th>
<th>Age</th>
<th>Birthday</th>
</tr>
<tbody id="myTable">
</tbody>
</table>
<script>
var myArray = [
{ "status": "OK", "passings" : [{"passtime": "16:20:29",
"runnerName": "Andrew Blyth",
"class": "H45",
"control": 1000,
"controlName" : "",
"time": "111:26" },{"passtime": "16:12:15",
"runnerName": "Erica Blyth",
"class": "D21",
"control": 1000,
"controlName" : "",
"time": "108:09" },{"passtime": "15:59:54",
"runnerName": "Björn Normark",
"class": "H21",
"control": 1000,
"controlName" : "",
"time": "felst." }], "hash": "4d3d4a2d9d3fefe360568918ed63cc99"} ]
buildTable(myArray)
function buildTable(data){
var table = document.getElementById('myTable')
for (var i = 0; i < data.length; i++){
var row = `<tr>
<td>${data[i].status}</td>
<td>${data[i].runnerName}</td>
<td>${data[i].class}</td>
</tr>`
table.innerHTML += row
}
}
</script>
I´m sorry if this is totally newbie questions, but last time i was into some webpage development .css just had became a thing!
Regards /Sebbe