Get rows from mysql table to php arrays

前端 未结 5 2045
借酒劲吻你
借酒劲吻你 2021-02-04 10:10

How can i get every row of a mysql table and put it in a php array? Do i need a multidimensional array for this? The purpose of all this is to display some points on a google ma

5条回答
  •  闹比i
    闹比i (楼主)
    2021-02-04 10:20

    HERE IS YOUR CODE, USE IT. IT IS TESTED.

    $select=" YOUR SQL QUERY GOOES HERE";
    $queryResult= mysql_query($select);
    
    //DECLARE YOUR ARRAY WHERE YOU WILL KEEP YOUR RECORD SETS
    $data_array=array();
    
    //STORE ALL THE RECORD SETS IN THAT ARRAY 
    while ($row = mysql_fetch_array($queryResult, MYSQL_ASSOC)) 
    {
        array_push($data_array,$row);
    }
    
    
    mysql_free_result($queryResult);
    
    
    //TEST TO SEE THE RESULT OF THE ARRAY 
    echo '
    ';
    print_r($data_array);
    echo '
    ';

    THANKS

提交回复
热议问题