Run a SQL query in JS

后端 未结 4 494
挽巷
挽巷 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:54

    Execute your query out side the JS and pass the prices in the javascript .

    Example :

    $res_price = $conn -> query("SELECT price FROM list WHERE q=1");
    $row_price = mysqli_fetch_assoc($res_price);
    
    echo $row_price['price'];
    

    Now in Javascript add Like,

    
    

    If you want add more than one prices then you can manage it through array also make array of price and pass it in the js.

提交回复
热议问题