Query SQL DB Table view and display results in HTML table
<p>my purpose is to display in a HTML table the result of a query to a remote ODBC SQL database with PHP.
I've already established the connection with the database, but when i try to execute a query and display it in a table it doesn't show anything.
Is there a difference in the query syntax if the table is a view?
The environment is WAMP installed on Windows, PHP 5.6.19, APACHE 2.4.18</p>

<p>This is the code (I have omitted the variables for the odbc connection):</p>

<pre><code>    &lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;style&gt;
table, th, td {
     border: 1px solid black;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;?php


$conn=odbc_connect("Driver={SQL Server};Server=$server;Database=$database;", $user, $password);

if( $conn ) {
     echo "Connection established.&lt;br /&gt;";
}else{
     echo "Connection could not be established.&lt;br /&gt;";
     die( print_r( odbc_error(), true));

     $sql = "SELECT * FROM ASSET_VIEW";
$result = $conn-&gt;query($sql);

if ($result-&gt;num_rows &gt; 0) {
    echo "&lt;table&gt;&lt;tr&gt;&lt;th&gt;numero&lt;/th&gt;&lt;/tr&gt;";
    // output data of each row
    while($row = $result-&gt;fetch_assoc()) {
        echo "&lt;tr&gt;&lt;td&gt;".$row["N_IMMA"]."&lt;/td&gt;&lt;/tr&gt;";
    }
    echo "&lt;/table&gt;";
} else {
    echo "0 results";
}
$conn-&gt;close();
}



?&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>All I get is the "Connection established" string and that's it.
I would like to show all the results from the table (about 30 columns and 300 rows). I've tried with different tables but I still get the same result. I'm relatively new to PHP and MySql and maybe it's a silly request but I can't get my head around it for the moment.</p>

<p>Thank you</p>