"R.S. Herhuth" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > I'm trying to build a dynamic script that basically extracts all of the > fields in a MS SQL database...I just can't seem to figure out how to get > at the field names themselves. I am using the mssql_fetch_array > followed by the $row['field_name'] in an array. But I would like to > make the field_name dynamic (i.e. not knowing the field_names ahead of > time) which would make the script adaptable to any table in the > database. So if I get the field's value by $row['field_name'] how do I > get at the field's name? > > thanks, > Ron
Hey. The best way to go about getting the name of fields in any given table is this: (connection to database assumed) <?php $query = select * from table; $fields = mssql_num_fields ($query); echo "<table border=\"1\">\n"; echo "<tr>\n"; for ($a = 1; $a < $fields; $a++) { echo "<td>" . mssql_field_name ($a) . "</td>\n"; } echo "</tr>\n"; echo "</table>\n"; ?> Hope this helps, I've just converted how I do it in MySQL to the functions for mssql. Brad -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php