I have the following php script which returns a string of numbers with commas separating them:
<?php include "printqueryrows.php"; ?>
returns
2.00 , 1.00 , 21.16 , 6.75 , 6.00 , 6.25 , 3.00 ,
I have a javascript chart creator that requires the data in the following format:
<script type="text/javascript"> ...
{
name: 'London',
data: [2.00 , 1.00 , 21.16 , 6.75 , 6.00 , 6.25 , 3.00 , ]
}
</script>
In order to include the results from the php file in the data field (so that it prints out the numbers, separated by commas, I use this script:
<script type="text/javascript"> ...
data: [<?php include "printqueryrows.php"; ?>]
</script>
However, this is not printing the data. If I do this line individually in another script, the data prints. But it doesn't print when I try to print it into this javascript file. Any suggestions? Thanks!
data: etcwithout curly brackets?var queryrows = <?php include "printqueryrows.php"; ?>;in a script tag. Then after put eitheralert(queryrows);orconsole.log(queryrows)to check the value is being set correctly