Create HTML table with data from any query using sqlsrv
Posted on 2016-08-23
I am trying to create a piece of code to display the contents of a query in a table, using php, sqlserver and sqlsrv_query.
I can build the body if the table, but the headers are not quite so easy. I don't believe that there is such a command as sqlsrv_fetch_field like the old mssql_fetch_field commend.
my code so far is...
//retrieve data from query...
$fields_num = mysql_num_fields($result);
// printing table headers
for($i=0; $i<$fields_num; $i++)
$field = sqlql_fetch_field($result);
while($row = sqlsrv_fetch_row($result))
// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
foreach($row as $cell)
This produces the table body, but leaves the column names in the first row blank.
I'd appreciate any help!