May 2005
Intermediate to advanced
352 pages
14h 39m
English
mysql_field_table( )
mysql_field_table(results,index)
This 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.
...
$sql_stmnt = "SELECT wrid, client_name, description
FROM workreq, clients
WHERE workreq.clientid = clients.clientid";
$results = mysql_db_query('workrequests', $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 in this example 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 the previous
script:
workreq.wrid clients.client_name workreq.description
Read now
Unlock full access