下面是我使用的代码,它可以工作,但只获取行而不是列,我将数据导入谷歌图表工具图表,它使用第一行作为列信息,使其不准确。
有没有办法获取列名并将其添加到数组中?
<?php
require "connectioninfo.php";
if ($databaseConnection == false)
{
echo "<p>Database connection failed...</p>";
}
else
{
$query = "SELECT * FROM avTable";
$statement = sqlsrv_query($databaseConnection, $query);
echo $statement;
while ($row = sqlsrv_fetch_array($statement))
{
$rows[] = array($row['BusinessName'],$row['Hygiene']);
}
$dataTable = json_encode($rows,JSON_NUMERIC_CHECK);
sqlsrv_free_stmt($statement);
}
sqlsrv_close($databaseConnection);
?>