Here is PHP code that I am using to read values from my MySQL database.
I am accesing the values stored in my table 'data'. I want to read all the data present in the column 'val' and them pass them to JavaScript.
<?php
mysql_connect("localhost", "root", "root") or die(mysql_error());
mysql_select_db("db") or die(mysql_error());
$query = "SELECT data.val from data";
$i=0;
$result = mysql_query($query) or die(mysql_error());
$i=0;
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result))
{
echo $row[$i];
echo "<br />";
}
?>
I now want to pass the values in $result to JavaScript, I am plotting a graph with the values by making use of D3.js.
Once posted I am making use of a var array store the points that need to be plotted on the graph.
How do I post the data from PHP to JavaScript?