我想在.JS文件中运行SQL查询.我尝试添加一些
PHP代码,但它当然没有用.
我想运行SQL查询:SELECT price FROM list WHERE q = 1.我想在图表中显示价格.有谁知道如何在.JS文件中运行此SQL查询,以便我可以从数据库中获取项目价格?
/* Morris.js Charts */
// Sales chart
var area = new Morris.Area({
element: 'revenue-chart',
resize: true,
data: [
{y: '2016 Q1', item1: 5000, item2: 4460},
{y: '2016 Q2', item1: 8432, item2: 5713}
],
xkey: 'y',
ykeys: ['item1', 'item2'],
labels: ['Item 1', 'Item 2'],
lineColors: ['#a0d0e0', '#3c8dbc'],
hideHover: 'auto'
});
var line = new Morris.Line({
element: 'line-chart',
resize: true,
data: [
{y: '2015 Q4', item1: 0},
{y: '2016 Q1', item1: 5000},
{y: '2016 Q2', item1: 8432}
],
xkey: 'y',
ykeys: ['item1'],
labels: ['Item 1'],
lineColors: ['#efefef'],
lineWidth: 2,
hideHover: 'auto',
gridTextColor: "#fff",
gridStrokeWidth: 0.4,
pointSize: 4,
pointStrokeColors: ["#efefef"],
gridLineColor: "#efefef",
gridTextFamily: "Open Sans",
gridTextSize: 10
});