I wrote a tool, that creates an array from a database (when the site is loaded) in php and would now like to use js functions to change the way this array is displayed in a table (different ranges, columns etc.).
How can I pass the php array to js, so I can use it in the js functions.
already tried this in the "script" section
<?php
$js_data = json_encode($data);
echo"var data = ".$js_data.";\n";
?>
function loadCompleteTable(){
table += '<table>';
for(var row in data){
table += '<tr>';
for(var col in data[row]){
table += '<td>';
table += data[row][col];
table += '</td>';
}
table += '</tr>';
}
table += '</table>';
document.getElementById("tablePlaceholder").innerHTML = table;
}