Collections:
odbc_fetch_row() - Looping through Result Set Objects
How To Loop through Result Set Objects using odbc_fetch_row()?
✍: Guest
If the returning output of a query statement is captured in a result set object, you can use odbc_fetch_row() to loop through each row in the output.
The tutorial PHP script below shows you how to list tables in the database:
<?php
$con = odbc_connect('FYI_SQL_SERVER','sa','FYIcenter');
$sql = "SELECT * FROM sys.objects"
. " WHERE type_desc='USER_TABLE'";
$res = odbc_exec($con, $sql);
print("User Tables:\n");
while (odbc_fetch_row($res)) {
print(" ".odbc_result($res,'name')."\n");
}
odbc_free_result($res);
odbc_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
⇒ odbc_result() - Retrieve Field Values
⇐ Returning Result from Query with ODBC Connection
⇑ SQL Server FAQs - PHP ODBC Functions - Connection and Query Execution
2024-06-30, 2327🔥, 0💬
Popular Posts:
How To Start Instance with a Minimal Initialization Parameter File in Oracle? The sample initializat...
What is SQL Server Transact-SQL (T-SQL)? SQL Server Transact-SQL, also called T-SQL, is an extension...
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...
How To View Data Files in the Current Database in Oracle? If you want to get a list of all tablespac...
How To Recover a Dropped Index in Oracle? If you have the recycle bin feature turned on, dropped ind...