I want to run a SQL query in a .JS file. I tried to add some PHP codes to it but it didn\'t work of course.
I want to run the SQL query: SELECT price FROM list WH
You can't directly connect to mysql with javascript but you can echo out your php variable in javascript like this..
var area = new Morris.Area({
element: 'revenue-chart',
resize: true,
data: [
{y: '2016 Q1', item1: , item2: },
{y: '2016 Q2', item1: 8432, item2: 5713}
]
you can cover the whole javascript inside php script.
this will replace like this on executing.
{y: '2016 Q1', item1: 12054, item2: 65242},