所以我有这个奇怪的问题我在sql studio中运行我的查询时有一堆值和列的表它可以工作但当我在我的网站上显示我的表时它到达日期列时它没有'显示它,它只显示一条记录,即使有很多现在我不知道为什么它这样做查询工作。它对此数据库中任何表的任何日期列执行此操作。我使用MSIS 2008与iis和PHP这里是我的代码。非常感谢任何帮助
<?php
echo "Door 1 Current State= Closed<br />";
echo "Door 2 Current State= Closed<br />";
echo "Door 3 Current State= Closed<br />";
echo "Door 4 Current State= Closed<br />";
echo "state1= Green State0 = Yellow state84=red stateA0 = Red state3=green<br />";
require('connection.php');
$query = "SELECT * FROM dbo.v_records";
$result = sqlsrv_query($conn, $query) or die (sqlsrv_errors());
if(sqlsrv_has_rows($result))
{
echo "<table border='1'>
<tr>
<th>ID</th>
<th>Card</th>
<th>Date</th>
<th>Dorr</th>
<th>Reader</th>
<th>Name</th>
<th>State</th>
</tr>";
while($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC))
{
echo "<tr>";
echo "<td>" . $row['ID'] . "</td>";
echo "<td>" . $row['Card'] . "</td>";
echo "<td>" . $row['Date'] . "</td>";
echo "<td>" . $row['ReaderN'] . "</td>";
echo "<td>" . $row['ReaderNo'] . "</td>";
echo "<td>" . $row['Name'] . "</td>";
echo "<td>" . $row['Warn'] . "</td>";
echo "</tr>";
}
echo "</table>";
}
else
{echo "No results were found.<br />";}
/* Close the connection. */
sqlsrv_close( $conn);
?>
我将此添加到循环SQLSRV_FETCH_ASSOC但它没有解决问题。我尝试创建一个视图并为列提供别名,但这也不起作用。
答案 0 :(得分:0)
像这样改变你的循环:
while($row = sqlsrv_fetch_array( $result, SQLSRV_FETCH_ASSOC) ) {
//...