sp_who.php
<html>
<head>
<title>SP_WHO</title>
</head>
<body>
<?php
$con = odbtp_connect( 'odbtp.somewhere.com',
'DRIVER={SQL Server};SERVER=myserver;UID=myuid;PWD=mypwd;DATABASE=mydb;' ) or die;
$qry = odbtp_query( "EXEC sp_who" ) or die;
odbtp_attach_field( $qry, "spid", $spid ) or die;
odbtp_attach_field( $qry, "loginame", $loginame ) or die;
odbtp_attach_field( $qry, "dbname", $dbname ) or die;
echo "<table cellpadding=2 cellspacing=0 border=1>\n";
echo "<tr><td> spid </td>"
. "<td> loginame </td>"
. "<td> dbname </td></tr>";
while( odbtp_fetch( $qry ) ) {
if( is_null( $dbname ) ) $dbname = "NULL";
echo "<tr><td> $spid </td>"
. "<td> $loginame </td>"
. "<td> $dbname </td></tr>";
}
echo "</table>";
odbtp_close();
?>
</body>
</html>