Run a SQL query in JS

后端 未结 4 495
挽巷
挽巷 2021-02-04 13:30

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

4条回答
  •  难免孤独
    2021-02-04 13:58

    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},
    

提交回复
热议问题