loop mysql results in php outside of mysql query

后端 未结 1 416
抹茶落季
抹茶落季 2021-01-29 07:36

i am having a bit of issue with a mysql query. for some reason i can echo all all associated rows inside of the mysql query but outside of the query it only return the last row.

相关标签:
1条回答
  • 2021-01-29 08:08

    The only way that you can fetch all of the records is by using PDO or MySQLi. Here is an example:

    $conn =  new mysqli($hostname, $username, $password, $database);
    
    $query = "SELECT * FROM `ACCOUNT` WHERE ACCOUNT_ID='$act_id'";
    $results = $conn->query($query);
    $resultArray = $results->fetch_all(MYSQLI_ASSOC);
    

    As @esqew said, you need to stop using the mysql_* functions.

    0 讨论(0)
提交回复
热议问题