MySQL query not working while using php variable in where clause

后端 未结 3 1153
忘了有多久
忘了有多久 2021-01-23 16:02

I\'m new to PHP and MySQL. I am trying to make a simple search form using which I would want to show the results from the database based on the input text entered in the form. M

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-23 16:21

    This should work:

    $query = "SELECT * FROM cats WHERE name = '$name'";

    Also, when you call "exit;" in the following block it will cancel the execution of the rest of your script:

        if (!empty($results)){
         echo "query successful" ;
         exit;
        }
    

提交回复
热议问题