For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Thursday, August 14, 2014

PHP with MSSql Server Stored procedure return records

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
*/
?>
Share:

0 comments:

Post a Comment

Multiple attribute passing in querySelectorAll

Multiple attribute passing in querySelectorAll     Here I am demonstrating code to how to pass multiple attributes in querySelectorAll. <...

Ads Inside Post

Powered by Blogger.

Arsip