How to use PHP & Access (odbc) Get Field Name This is tutorial php developers how to using PHP get field name from a microsoft access database.
ShotDev Focus:
- PHP & Get field name from table.
Example
php_list_table.php
<html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <? $objConnect = odbc_connect("mydatabase","",""); $strSQL = "SELECT * FROM customer"; $objExec = odbc_exec($objConnect, $strSQL) or die ("Error Execute [".$strSQL."]"); $intNumField = odbc_num_fields($objExec); $i = 0; echo "<b>Table customer have $intNumField Fields.</b><br>"; for($i=1;$i<=$intNumField;$i++) { echo $i."=".odbc_field_name($objExec,$i)." (".odbc_field_type($objExec,$i).")<br>"; } odbc_close($objConnect); ?> </body> </html>
Create a php file and save to path root-path/myphp/
Run
http://localhost/myphp/php_list_table.php
Screenshot