Collections:
mssql_fetch_array() - Looping through Result Set Objects
How To Loop through Result Set Objects using mssql_fetch_array()?
✍: Guest
If the returning output of a query statement is captured in a result set object, you can use mssql_fetch_array() to loop through each row in the output.
The tutorial PHP script below shows you how to list tables in the database:
<?php
$con = mssql_connect('LOCALHOST','sa','FYIcenter');
mssql_select_db('FyiCenterData', $con);
$sql = "SELECT * FROM sys.objects"
. " WHERE type_desc='USER_TABLE'";
$res = mssql_query($sql, $con);
print("User Tables:\n");
while ($row = mssql_fetch_array($res)) {
print(" ".$row{'name'}."\n");
}
mssql_free_result($res);
mssql_close($con);
?>
If you run this script, you will get something like:
User Tables: fyi_rates fyi_team fyi_random fyi_links_indexed fyi_links fyi_links_copy tipBackup2
⇒ mssql_result() - Retrieve Field Values
⇐ Returning Result from Query with MSSQL Connection
⇑ SQL Server FAQs - PHP MSSQL Functions - Connections and Query Execution
2024-03-23, 2208🔥, 0💬
Popular Posts:
How To Calculate DATETIME Value Differences Using the DATEDIFF() Function in SQL Server Transact-SQL...
What is sqlservr.exe - Process - SQL Server (SQLEX?PRESS) in SQL Server? Process sqlservr.exe is the...
How REAL and FLOAT Literal Values Are Rounded in SQL Server Transact-SQL? By definition, FLOAT(n) sh...
How To Format DATETIME Values to Strings with the CONVERT() Function in SQL Server Transact-SQL? SQL...
How Run SQL*Plus Commands That Are Stored in a Local File in Oracle? If you have a group of commands...