Hi
how to retrieve records using php and mssql?
mssql_query Quote:
mixed mssql_query ( string $query , resource $link_identifier , int $batch_size = 0)
send query to the sql server to the associated database , return true if success or false on error.
if link_identifier is not present means assumed the last opened link .
the following sample is used to retrieve records from database and display
Code:
<?php
$myServer = ".\SQLEXPRESS";
$myUser = "sa";
$myPass = "test";
$myDB = "testdb";
$dbhandle = mssql_connect($myServer, $myUser, $myPass,true);
echo mysql_error();
mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
$query = "SELECT empid,empname ";
$query .= "FROM test";
$result = mssql_query($query);
$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";
echo "<ul>";
while($row = mssql_fetch_array($result))
{
echo "<li>" . $row["empid"] . $row["empname"] . $row["year"] . "</li>";
}
echo "</ul>";
mssql_close($dbhandle);
?>