Fetching data from MySQL database to html drop-down list

前端 未结 3 1773
清歌不尽
清歌不尽 2021-01-29 07:41

I search for answers here but haven\'t found a solution. I have also added picture of the error. I want the data to go to the first drop-down list ( above the error) I think th

3条回答
  •  梦如初夏
    2021-01-29 08:03

    In MySQLi, the first parameter of a query needs to be the database connection. Also, there's no need to add a \ before the statement.

    $sql = \mysqli_query("SELECT name From users"); should be $sql = mysqli_query($con, "SELECT name From users");

    Note: replace $con with your database connection variable!

    As you mentioned that you wanted the result from the database to go inside the select form, simply adjust your code to look like this:

    
    

提交回复
热议问题