How can I obtain the Access field name in php? today, I have obtained the Access database data, but how can I obtain the table field name? & nbsp; I have obtained all the fields in the table without displaying numbers & nbsp; how can I obtain the Access field name in php?
Today, I have obtained the data used in the Access Database. but how can I obtain the table field name?
All the obtained fields are numerical fields that do not display table names.
// ================================================ ======================================
// Get record list
// Obtain the record list
// ================================================ ======================================
Public function getlist ($ table, $ field, $ fieldnum, $ condition = "", $ sort = "") // retrieves the record list
{
$ SQL = "SELECT". $ field. "FROM". $ table. "". $ condition. "". $ sort;
$ Query = $ this-> query ($ SQL );
$ I = 0;
While ($ this-> fetch_row ($ query ))
{
For ($ j = 0; $ j <$ fieldnum; $ j ++)
{
$ Info [$ j] = odbc_result ($ query, $ j + 1 );
}
$ Rdlist [$ I] = $ info;
$ I ++;
}
Return $ rdlist;
}
This is my method.
------ Solution --------------------
I have never used odbc. check whether there are any methods like mysql_fetch_array () mysql_fetch_assoc (). you can directly use the field name in the table.
------ Solution --------------------
Odbc_field_name
------ Solution --------------------
The mysql_list_fields () function returns the field name of the table.
------ Solution --------------------
Odbc_fetch_into
------ Solution --------------------
$ Connstr = "DRIVER = Microsoft Access Driver (*. mdb); DBQ =". realpath ("cust. mdb ");
$ Conn = odbc_connect ($ connstr, "", "", SQL _CUR_USE_ODBC );
$ Query = odbc_do ($ conn, "select * from yhxx ");
// Output record
While (odbc_fetch_row ($ query ))
{
$ Id = odbc_result ($ query, id );
$ Gonghao = odbc_result ($ query, gonghao );
Echo $ id;
Echo"
";
Echo $ gonghao;
Echo"
";
}
// Output field
$ Num_field = max (odbc_num_fields ($ query), $ num_field );
For ($ I = 0; $ I
Echo @ odbc_field_name ($ query, $ I + 1 );
Echo"
";
}
Odbc_close ($ conn );
?>