Fetch all rows based on the query into an array

前端 未结 2 2003
萌比男神i
萌比男神i 2021-01-17 01:03

I have the following code:

  //--------------------------------------------------------------------------
  // 2) Query database for data
  //---------------         


        
2条回答
  •  Happy的楠姐
    2021-01-17 02:03

    Try:

    $result = mysql_query("SELECT * FROM $tableName");
    while($row = mysql_fetch_array($result)) {
        $array[]=array($row[0], $row[1],...);
    }
    

    This will generate a multidimentional array where the subarray contains your values.

提交回复
热议问题