Collections:
mssql_result() - Retrieve Field Values
How To Retrieve Field Values using mssql_result()?
✍: Guest
Once the result set is captured in an object, you can think of it as a "table" with rows and columns (fields). You can use mssql_result() to retrieve the value of any given row and column (field) with this formats:
$value = mssql_result($res, $row, $column); #- $row is the row number, starting with 0 #- $column is the column number, starting with 0
The tutorial PHP script below shows you how to list tables in the database with multiple field values:
<?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");
for ($i=0; $i<mssql_num_rows($res); $i++) {
print(" ".mssql_result($res,$i,0));
print(", ".mssql_result($res,$i,1));
print(", ".mssql_result($res,$i,6)."\n");
}
mssql_free_result($res);
mssql_close($con);
?>
If you run this script, you will get something like:
User Tables: fyi_rates, 85575343, USER_TABLE fyi_team, 165575628, USER_TABLE fyi_random, 821577965, USER_TABLE fyi_links_indexed, 1061578820, USER_TABLE fyi_links, 1093578934, USER_TABLE fyi_links_copy, 1253579504, USER_TABLE tipBackup2, 2121058592, USER_TABLE
⇒ mssql_field_name() - Retrieve Field Names
⇐ mssql_fetch_array() - Looping through Result Set Objects
⇑ SQL Server FAQs - PHP MSSQL Functions - Connections and Query Execution
2024-03-23, 1936🔥, 0💬
Popular Posts:
How To View Data Files in the Current Database in Oracle? If you want to get a list of all tablespac...
What Is SQL*Plus in Oracle? SQL*Plus is an interactive and batch query tool that is installed with e...
What Is an Oracle Tablespace in Oracle? An Oracle tablespace is a big unit of logical storage in an ...
How To Use SQL*Plus Built-in Timers in Oracle? If you don't have a stopwatch/timer and want to measu...
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...