Connect PHP with MSSql Server Stored procedure and return records.
<?php
$sqlServerIP = '127.0.0.1';
$link = mssql_connect($sqlServerIP, 'sa', 'amit123');
if (!$link) {
die('wrong connection');
}
mssql_select_db('amittest', $link);
$stmt = mssql_init('ListEmp');
$ID = 100;
mssql_bind($stmt, '@ID', $ID, SQLINT4, false, false, 4);
$result=mssql_execute($stmt);
$num = mssql_num_rows($result);
if($num>0) {
while($row = mssql_fetch_assoc($result)) {
echo "<li>" . $row['ID'] . $row['EmpID']."</li>";
}
mssql_free_statement($stmt);
}
else {
echo "No records found";
}
echo mssql_get_last_message();
/*
CREATE PROCEDURE dbo.ListEmpmp
@ID bigint
as
begin
select ID,EmpID from Employee where ID>=@ID
End
*/
?>
<?php
$sqlServerIP = '127.0.0.1';
$link = mssql_connect($sqlServerIP, 'sa', 'amit123');
if (!$link) {
die('wrong connection');
}
mssql_select_db('amittest', $link);
$stmt = mssql_init('ListEmp');
$ID = 100;
mssql_bind($stmt, '@ID', $ID, SQLINT4, false, false, 4);
$result=mssql_execute($stmt);
$num = mssql_num_rows($result);
if($num>0) {
while($row = mssql_fetch_assoc($result)) {
echo "<li>" . $row['ID'] . $row['EmpID']."</li>";
}
mssql_free_statement($stmt);
}
else {
echo "No records found";
}
echo mssql_get_last_message();
/*
CREATE PROCEDURE dbo.ListEmpmp
@ID bigint
as
begin
select ID,EmpID from Employee where ID>=@ID
End
*/
?>
0 comments:
Post a Comment