<ol
class
=
"dp-xml"
>
<li
class
=
"alt"
><span><span
class
=
"tag"
><span> ?php </span></span></span></li>
<li>
<span>$</span><span
class
=
"attribute"
>myServer</span><span> = </span><span
class
=
"attribute-value"
>localhost</span><span>;
</li>
<li
class
=
"alt"
>
<span>$</span><span
class
=
"attribute"
>myUser</span><span> = </span><span
class
=
"attribute-value"
>sa</span><span>;
</li>
<li>
<span>$</span><span
class
=
"attribute"
>myPass</span><span> = </span><span
class
=
"attribute-value"
>password</span><span>;
</li>
<li
class
=
"alt"
>
<span>$</span><span
class
=
"attribute"
>myDB</span><span> = </span><span
class
=
"attribute-value"
>Northwind</span><span>;
</li>
<li>
<span>$</span><span
class
=
"attribute"
>s</span><span> = @mssql_connect(
$myServer
,<br>
$myUser
,
$myPass
) </span>
</li>
<li
class
=
"alt"
><span>
or
die
(Couldnt connect to <br>SQL Server on
$myServer
); </span></li>
<li>
<span>$</span><span
class
=
"attribute"
>d</span><span> = @mssql_select_db(
$myDB
,
$s
) </span>
</li>
<li
class
=
"alt"
><span>
or
die
(Couldnt open database
$myDB
); </span></li>
<li>
<span>$</span><span
class
=
"attribute"
>query</span><span> = </span><span
class
=
"attribute-value"
>SELECT</span><span> TitleOfCourtesy<br>+ +FirstName+ +LastName AS Employee ; </span>
</li>
<li
class
=
"alt"
>
<span>
$query
</span><span
class
=
"attribute"
>.</span><span>= </span><span
class
=
"attribute-value"
>FROM</span><span> Employees ; </span>
</li>
<li>
<span>
$query
</span><span
class
=
"attribute"
>.</span><span>= </span><span
class
=
"attribute-value"
>WHERE</span><span> </span><span
class
=
"attribute"
>Country</span><span>=</span><span
class
=
"attribute-value"
>USA</span><span> <br>AND Left(HomePhone, 5) = (206); </span>
</li>
<li
class
=
"alt"
>
<span>$</span><span
class
=
"attribute"
>result</span><span> = </span><span
class
=
"attribute-value"
>mssql_query</span><span>(
$query
); </span>
</li>
<li>
<span>$</span><span
class
=
"attribute"
>numRows</span><span> = </span><span
class
=
"attribute-value"
>mssql_num_rows</span><span>(
$result
); </span>
</li>
<li
class
=
"alt"
>
<span>
echo
</span><span
class
=
"tag"
><span
class
=
"tag-name"
>h1</span><span
class
=
"tag"
>></span><span> .
$numRows
. Row .<br> ($</span><span
class
=
"attribute"
>numRows</span><span> == 1 ? : s) . Returned </span><span
class
=
"tag"
> </span><span
class
=
"tag-name"
>h1</span><span
class
=
"tag"
>></span><span>; </span></span>
</li>
<li>
<span>
while
($</span><span
class
=
"attribute"
>row</span><span> = </span><span
class
=
"attribute-value"
>mssql_fetch_array</span><span>(
$result
)) </span>
</li>
<li
class
=
"alt"
><span>{ </span></li>
<li>
<span>
echo
</span><span
class
=
"tag"
><span
class
=
"tag-name"
>li</span><span
class
=
"tag"
>></span><span> .
$row
[Employee] . </span><span
class
=
"tag"
><span
class
=
"tag-name"
>li</span><span
class
=
"tag"
>></span><span>; </span></span></span>
</li>
<li
class
=
"alt"
><span>} </span></li>
<li>
<span
class
=
"tag"
>?></span><span> </span>
</li>
</ol>