<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Get name of the table the specified field is in</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.mysql-field-seek.html">mysql_field_seek</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.mysql-field-type.html">mysql_field_type</a></div> <div class="up"><a href="ref.mysql.html">MySQL Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.mysql-field-table" class="refentry"> <div class="refnamediv"> <h1 class="refname">mysql_field_table</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">mysql_field_table</span> — <span class="dc-title">Get name of the table the specified field is in</span></p> </div> <div id="function.mysql-field-table-refsynopsisdiv"> <div class="warning"><strong class="warning">Warning</strong> <p class="para">This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the <a href="book.mysqli.html" class="link">MySQLi</a> or <a href="ref.pdo-mysql.html" class="link">PDO_MySQL</a> extension should be used. See also <a href="mysqlinfo.api.choosing.html" class="link">MySQL: choosing an API</a> guide and <a href="faq.databases.html#faq.databases.mysql.deprecated" class="link">related FAQ</a> for more information. Alternatives to this function include:</p> <ul class="simplelist"> <li class="member"><span class="function"><a href="mysqli-result.fetch-field-direct.html" class="function">mysqli_fetch_field_direct()</a></span> [table] or [orgtable]</li> <li class="member"><span class="methodname"><a href="pdostatement.getcolumnmeta.html" class="methodname">PDOStatement::getColumnMeta()</a></span> [table]</li> </ul> </div> </div> <div class="refsect1 description" id="refsect1-function.mysql-field-table-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><strong>mysql_field_table</strong></span> ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$result</code></span> , <span class="methodparam"><span class="type">int</span> <code class="parameter">$field_offset</code></span> )</div> <p class="para rdfs-comment"> Returns the name of the table that the specified field is in. </p> </div> <div class="refsect1 parameters" id="refsect1-function.mysql-field-table-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <code class="parameter"> result</code></dt> <dd> <p class="para">The result <span class="type"><a href="language.types.resource.html" class="type resource">resource</a></span> that is being evaluated. This result comes from a call to <span class="function"><a href="function.mysql-query.html" class="function">mysql_query()</a></span>.</p></dd> <dt> <code class="parameter"> field_offset</code></dt> <dd> <p class="para">The numerical field offset. The <code class="parameter">field_offset</code> starts at <em>0</em>. If <code class="parameter">field_offset</code> does not exist, an error of level <strong><code>E_WARNING</code></strong> is also issued.</p></dd> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.mysql-field-table-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> The name of the table on success. </p> </div> <div class="refsect1 examples" id="refsect1-function.mysql-field-table-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-2193"> <p><strong>Example #1 A <span class="function"><strong>mysql_field_table()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br />$query </span><span style="color: #007700">= </span><span style="color: #DD0000">"SELECT account.*, country.* FROM account, country WHERE country.name = 'Portugal' AND account.country_id = country.id"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// get the result from the DB<br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Lists the table name and then the field name<br /></span><span style="color: #007700">for (</span><span style="color: #0000BB">$i </span><span style="color: #007700">= </span><span style="color: #0000BB">0</span><span style="color: #007700">; </span><span style="color: #0000BB">$i </span><span style="color: #007700">< </span><span style="color: #0000BB">mysql_num_fields</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">); ++</span><span style="color: #0000BB">$i</span><span style="color: #007700">) {<br /> </span><span style="color: #0000BB">$table </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_field_table</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">, </span><span style="color: #0000BB">$i</span><span style="color: #007700">);<br /> </span><span style="color: #0000BB">$field </span><span style="color: #007700">= </span><span style="color: #0000BB">mysql_field_name</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">, </span><span style="color: #0000BB">$i</span><span style="color: #007700">);<br /><br /> echo </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$table</span><span style="color: #DD0000">: </span><span style="color: #0000BB">$field</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 notes" id="refsect1-function.mysql-field-table-notes"> <h3 class="title">Notes</h3> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> For backward compatibility, the following deprecated alias may be used: <span class="function"><strong>mysql_fieldtable()</strong></span> </p> </p></blockquote> </div> <div class="refsect1 seealso" id="refsect1-function.mysql-field-table-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><span class="function"><a href="function.mysql-list-tables.html" class="function" rel="rdfs-seeAlso">mysql_list_tables()</a> - List tables in a MySQL database</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.mysql-field-seek.html">mysql_field_seek</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.mysql-field-type.html">mysql_field_type</a></div> <div class="up"><a href="ref.mysql.html">MySQL Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>