I am trying to display the result from a query in to a table. I can do this pretty easily when doing queries from mysql, but cannot get it to work with mssql. Below is the code I used to actually make sure I could get the data (and it works fine). I just cannot figure out how to get it to display in a table. If anyone could point me in the right direction I would appreciate it.
<?php
$myServer = "server";
$myUser = "user";
$myPass = "password";
$myDB = "db";
//Connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
//Select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
//Declare the SQL statement that will query the database
$query = "SELECT col1, col2 ";
$query .= "FROM sqltable ";
//Execute the SQL query and return records
$result = mssql_query($query)
or die('A error occured: ' . mysql_error());
//Show result
while ( $record = mssql_fetch_array($result) )
{
echo $record["col1"] . " , " . $record["col2"] . "<br />";
}
//Free result set memory
mssql_free_result($result);
//Close the connection
mssql_close($dbhandle);
?>