I am using a jquery flot map and i want to add a php variable to generate the values, I thinki have done something like this before but just cannot get it to work. I have two pages the first is the stats page which calls the chart as a class and displays the information from the flot.js page.
Below is a snippet of the code where it shows how the variables are put together.
var d1 = [];
for (var i = 1; i <= 14; i += 1)
d1.push([i, parseInt(Math.random() * 45000)]);
what i want to do is add a variable to the page something like this,
var d1 = [];
for (var i = 1; i <= 14; i += 1)
d1.push([i, parseInt(Math.random() * <?php echo $test ?>)]);
with the value of the test var being set in the stats page before the flot.js page is called if that all makes sense.
At the moment the graph works fine in it's original state but as soon as I add a php var to the page it displays nothing, any advice would be appreciated.
.jsfile will need to be a.phpfile to allow PHP code inside of it. Setting one variable in your "stats page" won't automatically cause PHP to execute your JS file as PHP code on the server - you need to explicitly run it as such.