PHP - Javascript Arrays

Let me explain my question/task:

  1. I have a PHP table showing temperature at a certain date and time, with API from a weather forecast. 2) Job is: translate this table into a line graph with Javascript. 3) I need to create a link between the PHP table and my Javascript code. But how do I do this using ‘arrays’? 4) My current method: using an id tag for each td row in the PHP table. Next, making a for loop which checks the PHP table 40 times (the number of datapoints I need for the chart), to collect the next td row (unfortunately I get 40 times the same value).

Shortly, how can I use the table data and make it ‘available’ in Javascript to create a line chart from as a visualt representation of the temperature.

Here under you can find my current coding in PHP and Javascript. Any feedback, help or advise is very welcom! Thank you upfront!

PHP-part for loop:

echo "\<table\>";for($j=0; $j \<40; $j++){ echo "\<tr\>"; echo "\<td id=Temp\>{$data-\>list[$j]-\>main-\>temp}\</td\>"; echo "\<td id=Datum\>{$data-\>list[$j]-\>dt\_txt}\</td"; echo "\</tr\>";}echo "\</table\>";


var temp =newArray();var datum =newArray();for(var i=0; i \<40; i++){ temp[i]= document.getElementById("Temp").innerText; datum[i]= document.getElementById("Datum").innerText;}

Greetz, C.