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

How to make center align child div

 How to make center align child div?   Suppose you have 2 Div tag. And want the make inner tag center <div id="d1">      ...

Ads Inside Post

Powered by Blogger.

Arsip