Displaying an associative array in PHP

前端 未结 6 1956
南旧
南旧 2021-01-23 04:20

I am trying to build a function that extracts information from a database and inserts it into an associative array in PHP using mysql_fetch_assoc, and return the ar

6条回答
  •  甜味超标
    2021-01-23 04:43

    This should get you going:

    $rows = mysql_query("select * from whatever");
    if ($rows) {
       while ($record = mysql_fetch_array($rows)) {
           echo $record["column1"];
           echo $record["column2"];
           // or you could just var_dump($record); to see what came back...
       }
    }
    

提交回复
热议问题