mysql_field_table()
string mysql_field_table(results,index)
This function returns the name of the table that contains a particular field from the results set given. An offset for the field is given as the second argument. This is useful for a results set derived from an SQL statement involving multiple tables. Here is an example:
...
$sql_stmnt = "SELECT wrid, client_name, description
FROM workreq, clients
WHERE workreq.clientid = clients.clientid";
$results = mysql_query($sql_stmnt);
$num_fields = mysql_num_fields($results);
for ($index = 0; $index < $num_fields; $index++) {
$table = mysql_field_table($results, $index);
$field = mysql_field_name($results, $index);
print "$table.$field \n";
}
...The SQL statement here selects columns from two different
tables. Using mysql_field_table() inside of
the for statement, the code determines the name of
the table from which each field comes. The
mysql_field_name() function gets the field’s
name. Here are the results of this script:
workreq.wrid clients.client_name workreq.description