put table field names into an array
I am using PHP with a MySQL database.
I am wondering if it's possible to get the field names of a table dynamically and put them into an array? I would also be nice to dynamically get a list of tables in the database also. So if a table is added or a field is added I don't have to change my code.
In VBScript you can do a recordset(iFieldPosition).Name and get the name of the field.
Currently the only why I have seen in php is to hardcode the field name you want to work with. Example:
while ($row = mysql_fetch_array($sql_result)) {
$variable1 = $row["FIELD1"];
$variable2 = $row["FIELD2"];
}
Thanks in advance for your help.