What is wrong with this code that uses the mysql extension to fetch data from a database in PHP?

前端 未结 10 699
别跟我提以往
别跟我提以往 2021-01-17 06:18

I want to fetch data from a mysql table using php. Please, can anyone tell me what is wrong with this code? What is the correct code to fetch data from a mysql database:

10条回答
  •  别那么骄傲
    2021-01-17 06:48

    Try

    $query = mysql_query("SELECT * FROM users WHERE name = 'Admin' ")or die(mysql_error());

    and check if this throw any error.

    Then use while($rows = mysql_fetch_assoc($query)):

    And finally display it as

    echo $name . "
    " . $address . "
    " . $email . "
    " . $subject . "
    " . $comment . "

    " . ;

    Do not user mysql_* as its deprecated.

提交回复
热议问题