Create PHP array from MySQL column

前端 未结 11 975
花落未央
花落未央 2020-12-03 07:54

mysql_fetch_array will give me an array of a fetched row. What\'s the best way generate an array from the values of all rows in one column?

11条回答
  •  北海茫月
    2020-12-03 08:02

    Loop through the result:

    $result = mysql_query(...);
    $data = array();
    while ($row = mysql_fetch_array($result)) {
        array_push($data, $row["columnyouwant"]);
    }
    

提交回复
热议问题