Use php and MySql to connect to ODBC data. ODBC refers to the open data connection, which is a data driver led by Microsoft. it can be connected to other data and operated on data through the SQL language, of course, PHP also provides ODBC data connection. ODBC refers to the open data connection. it is a data driver dominated by Microsoft and can be connected to other data, the SQL language is used to operate data. of course, PHP also provides functions for ODBC data connection,
Using PHP to connect to ODBC mainly involves several functions,
First, let's first understand several functions with ODBC interfaces:
Int odbc_connect (string dsn, string user, string password, int [cursor_type]); connected to ODBC database
Dsn, user, and password correspond to the content in ODBC, and cursor_type is the choice of the cursor type (you can check other documents, here I use its default value)
Int odbc_do (int connection_id, string query); it is a function used to execute the SQL language. connecton_id is the value returned by odbc_connecti. query is the SQL language statement we are most concerned about,
String odbc_result (int result_id, mixed field); it is a function for retrieving data, result_id is the return value of odbc_do execution, and field is the field index value.
Void odbc_close (int connection_id); closes data connections.
We first use these functions to connect to ODBC.
We assume that you can set dsn to yuange user and password in ODBC. of course, if you want to connect to SQL Server, you need user and password!
There is a counter table in yuange.
$ Conid = odbc_connect ("yuange ","","");
$ SQL = "select * from counter ";
$ Resid = odbc_do ($ conid, $ SQL );
While (odbc_fetch_row ($ resid )){
$ Serial = odbc_result ($ resid, 1 );
$ Riqi = odbc_result ($ resid, 2 );
If ($ serial % 2 ){
Echo $ serial. "". $ riqi ."
";
}
}
Odbc_close ($ conid );
?>
I installed PWS with php4.0 and mysql3.02 on Win98, which worked well.
[This article is copyrighted by the author and osuo. if you need to reprint it, please indicate the author and its source]
Http://www.bkjia.com/PHPjc/316446.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/316446.htmlTechArticleODBC refers to the open data connection, it is the data driver of Microsoft, it can be connected with other data, through the SQL language to operate the data, of course, PHP also provides ODBC data connection...