w3resource logo


PHP mysql_field_table function

PHP : mysql_field_table() function

<<PreviousNext>>

Description

The mysql_field_table() function gets the name of the table, the specified field belongs to.

Version

(PHP 4 and above)

Syntax

mysql_field_table(result, field_offset)

Parameters

Name Description Required/ Optional Type
result Refers to the resource return by a valid mysql query, by calling mysql_query(). Required Resource
field_offset The numerical field position, starts with 0. In absence of field_offset an error level E_WARNING is generated. Required Integer

Return value

The name of the table on success.

Value Type : String.

Example :

<?php
$con = mysql_connect("localhost", "root", "mypass");
$selectdb = mysql_select_db("tutorials",$con);
$sql = "select * from tutorials";
$result = mysql_query($sql);
echo "<h2>List of the fields in the tutorials table:</h2>";>
for ($i = 0; $i < mysql_num_fields($result); ++$i) {
    $table_name = mysql_field_table($result, $i);
    $field_name = mysql_field_name($result, $i);
    echo  $table_name." : ".$field_name."<br />";
}
?>

Output :

List of the fields in the tutorials table:

tutorials : t_id
tutorials : name
tutorials : no_of_pages
tutorials : no_of_examples
tutorials : author

See also

PHP Function Reference

<<PreviousNext>>