ms sql fetch数组后的Echo不运行

时间:2015-03-20 02:56:06

标签: php sql-server

我有一个SMQL选择查询,它从MS Sql服务器检索数据,但是在mssql_query之后,我尝试通过一个使用mssql_fetch数组的循环来获取它,但似乎它正在跳过获取部分。这是我的代码。

<?php
 session_start();
 $account = $_REQUEST['name'];
 ?>
<html>
<head></head>
<body>
    <div>
         <?php
             echo "<table border='1' cellpadding='5'  width='100%''>";
            echo "<tr><th>No.</th><th>Location</th><th>Engine</th>   <th>Time</th></tr>";

        // Loop through database

        $sql = "SELECT * FROM locations where name = '$account' order by time desc";
        //die($sql);
        $result = mssql_query($sql);

          while ($row = mssql_fetch_array($result)) {
            $id = $row['id'];
            $location = $row['address'];
            $engine = $row['description'];
            $time = $row['time'];



            // Show entries
                echo    "<tr>
                         <td>".$id."</td>
                         <td>".$location."</td>
                         <td>".$engine."</td>
                         <td>".$time."</td>
                         </tr>";

        }

        echo "</table>";
        ?>
    </div>
</body>

0 个答案:

没有答案