How to get one column of mysql_query results into an array?

前端 未结 4 589
误落风尘
误落风尘 2021-01-28 02:04

I\'m selecting a single column from a MySQL table with mysql_query(). Is there already a function for getting the results into an array, or will I have to iterate t

4条回答
  •  一生所求
    2021-01-28 02:25

    you can do this with mysqli_fetch_all and array_column

    $r = mysqli_query($c,"SELECT bug_name FROM bugs WHERE color='red'");
    $bug_names = array_column(mysqli_fetch_all($r,MYSQLI_ASSOC),"bug_name");
    

提交回复
热议问题