How to use PHP & SQL Server (mssql) Get Field Name Learn / tutorial php programming how to using PHP get table field name from SQL Server database
ShotDev Focus:
- PHP & SQL Server get field name from table.
Example
php_sqlserver_list_table.php
- <html>
- <head>
- <title>ShotDev.Com Tutorial</title>
- </head>
- <body>
- <?
- $objConnect = mssql_connect("localhost","sa","");
- $objDB = mssql_select_db("mydatabase");
- $strSQL = "SELECT * FROM customer";
- $objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
- $intNumField = mssql_num_fields($objQuery);
- $i = 0;
- echo "<b>Table customer have $intNumField Fields.</b><br>";
- for($i=1;$i<$intNumField;$i++)
- {
- echo $i."=".mssql_field_name($objQuery,$i)." (".mssql_field_type($objQuery,$i).")<br>";
- }
- mssql_close($objConnect);
- ?>
- </body>
- </html>
Create a php file and save to path root-path/myphp/
Run
http://localhost/myphp/php_sqlserver_list_table.php
Screenshot