How to get the columns names along with resultset in php/mysql?

后端 未结 5 1155
生来不讨喜
生来不讨喜 2020-12-06 05:56

Is this OK ?

$i = 0;
while ($row = mysql_fetch_array($result))
{
    $resultset[] = $row;
    $columns[] = mysql_fetch_field($result, $i);
}
<
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-06 06:25

    Though it's deprecated and no longer in PHP 7 you can avoid having to use an object by using the function mysql_field_name instead which returns a string.

提交回复
热议问题