Create PHP array from MySQL column

前端 未结 11 974
花落未央
花落未央 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:20

    $result = mysql_query("SELECT columnname FROM table WHERE x=y");
    
    $columnValues = Array();
    
    while ( $row = mysql_fetch_assoc($result) ) {
    
      $columnValues[] = $row['columnname'];
    
    }
    

提交回复
热议问题