I have 2 php Files. [Insert.php & Output.php]
Insert.php: Catch 2 Dates and send it to the Output.php
Output.php: The 2 Dates go to an mysql Query. The result i'll save to an array.
while($myArray = mysqli_fetch_array($sqlresult)) {}
Now i want use this Array (myArray) in an separate js file to color the results.
while($myArray = mysqli_fetch_array($sqlresult)) {
echo $myArray["res1"];
echo "<script type='text/javascript'>
var stats = new Array(";
echo '"' . implode('","', $myArray) . '");';
echo "\n</script>";}
in the js file i have:
for (var x = 0; x < stats.length; x++) {
$(".class#" + stats[x]).css("background-color", "#e74c3c");
$(".class2#" + stats[x]).css("background-color", "#e74c3c");
alert(stats);
}
In my SQL Table i have insert 3 cols. [a1, a2 and a3]. He should color me this 3 ids [a1, a2, a3]. But he only take the first and alert me 2 times:
a1,a1
What i made wrong?