We will write a very simple PHP file to retrieve the data in the database
test.
Write the following PHP code to a file, and name it with the extension
name .php (like test01.php).
<html>
<head>
<title>My first PHP </title>
</head>
<body>
<?
// connect to the database.
$con = odbc_connect('test', 'SYSADM', "");
// get result handle
$rs = odbc_exec($con, 'select * from t1');
// fetch data
while (odbc_fetch_row($rs)) {
// get column data
$c1 = odbc_result($rs, 1);
$c2 = odbc_result($rs, 2);
// print out the result
echo "result --> c1 = $c1, c2 = $c2<br>";
}
// close the result
odbc_free_result($rs);
// close the connection
odbc_close($con);
?>
</body>
</html>
For the detailed information of these PHP functions, please reference
the PHP Manual (in php-manual.tgz).