PHP: Hypertext Preprocessor (original) (raw)

mysql_field_table

(PHP 4, PHP 5)

mysql_field_table — Get name of the table the specified field is in

Description

Returns the name of the table that the specified field is in.

Parameters

result

The result resource that is being evaluated. This result comes from a call tomysql_query().

field_offset

The numerical field offset. Thefield_offset starts at 0. Iffield_offset does not exist, an error of level**[E_WARNING](errorfunc.constants.php#constant.e-warning)** is also issued.

Return Values

The name of the table on success.

Examples

Example #1 A mysql_field_table() example

`<?php

$query

= "SELECT account., country. FROM account, country WHERE country.name = 'Portugal' AND account.country_id = country.id";// get the result from the DB result=mysqlquery(result = mysql_query(result=mysqlquery(query);// Lists the table name and then the field name
for ($i = 0; i<mysqlnumfields(i < mysql_num_fields(i<mysqlnumfields(result); ++$i) { table=mysqlfieldtable(table = mysql_field_table(table=mysqlfieldtable(result, i);<spanclass="katex"><spanclass="katex−mathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>f</mi><mi>i</mi><mi>e</mi><mi>l</mi><mi>d</mi><mo>=</mo><mi>m</mi><mi>y</mi><mi>s</mi><mi>q</mi><msub><mi>l</mi><mi>f</mi></msub><mi>i</mi><mi>e</mi><mi>l</mi><msub><mi>d</mi><mi>n</mi></msub><mi>a</mi><mi>m</mi><mi>e</mi><mostretchy="false">(</mo></mrow><annotationencoding="application/x−tex">field=mysqlfieldname(</annotation></semantics></math></span><spanclass="katex−html"aria−hidden="true"><spanclass="base"><spanclass="strut"style="height:0.8889em;vertical−align:−0.1944em;"></span><spanclass="mordmathnormal"style="margin−right:0.10764em;">f</span><spanclass="mordmathnormal">i</span><spanclass="mordmathnormal">e</span><spanclass="mordmathnormal"style="margin−right:0.01968em;">l</span><spanclass="mordmathnormal">d</span><spanclass="mspace"style="margin−right:0.2778em;"></span><spanclass="mrel">=</span><spanclass="mspace"style="margin−right:0.2778em;"></span></span><spanclass="base"><spanclass="strut"style="height:1.0361em;vertical−align:−0.2861em;"></span><spanclass="mordmathnormal">m</span><spanclass="mordmathnormal">ys</span><spanclass="mordmathnormal"style="margin−right:0.03588em;">q</span><spanclass="mord"><spanclass="mordmathnormal"style="margin−right:0.01968em;">l</span><spanclass="msupsub"><spanclass="vlist−tvlist−t2"><spanclass="vlist−r"><spanclass="vlist"style="height:0.3361em;"><spanstyle="top:−2.55em;margin−left:−0.0197em;margin−right:0.05em;"><spanclass="pstrut"style="height:2.7em;"></span><spanclass="sizingreset−size6size3mtight"><spanclass="mordmathnormalmtight"style="margin−right:0.10764em;">f</span></span></span></span><spanclass="vlist−s">​</span></span><spanclass="vlist−r"><spanclass="vlist"style="height:0.2861em;"><span></span></span></span></span></span></span><spanclass="mordmathnormal">i</span><spanclass="mordmathnormal">e</span><spanclass="mordmathnormal"style="margin−right:0.01968em;">l</span><spanclass="mord"><spanclass="mordmathnormal">d</span><spanclass="msupsub"><spanclass="vlist−tvlist−t2"><spanclass="vlist−r"><spanclass="vlist"style="height:0.1514em;"><spanstyle="top:−2.55em;margin−left:0em;margin−right:0.05em;"><spanclass="pstrut"style="height:2.7em;"></span><spanclass="sizingreset−size6size3mtight"><spanclass="mordmathnormalmtight">n</span></span></span></span><spanclass="vlist−s">​</span></span><spanclass="vlist−r"><spanclass="vlist"style="height:0.15em;"><span></span></span></span></span></span></span><spanclass="mordmathnormal">am</span><spanclass="mordmathnormal">e</span><spanclass="mopen">(</span></span></span></span>result,i); <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>f</mi><mi>i</mi><mi>e</mi><mi>l</mi><mi>d</mi><mo>=</mo><mi>m</mi><mi>y</mi><mi>s</mi><mi>q</mi><msub><mi>l</mi><mi>f</mi></msub><mi>i</mi><mi>e</mi><mi>l</mi><msub><mi>d</mi><mi>n</mi></msub><mi>a</mi><mi>m</mi><mi>e</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">field = mysql_field_name(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal">i</span><span class="mord mathnormal">e</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">d</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1.0361em;vertical-align:-0.2861em;"></span><span class="mord mathnormal">m</span><span class="mord mathnormal">ys</span><span class="mord mathnormal" style="margin-right:0.03588em;">q</span><span class="mord"><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3361em;"><span style="top:-2.55em;margin-left:-0.0197em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right:0.10764em;">f</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.2861em;"><span></span></span></span></span></span></span><span class="mord mathnormal">i</span><span class="mord mathnormal">e</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord"><span class="mord mathnormal">d</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">n</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">am</span><span class="mord mathnormal">e</span><span class="mopen">(</span></span></span></span>result, i);<spanclass="katex"><spanclass="katexmathml"><mathxmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>f</mi><mi>i</mi><mi>e</mi><mi>l</mi><mi>d</mi><mo>=</mo><mi>m</mi><mi>y</mi><mi>s</mi><mi>q</mi><msub><mi>l</mi><mi>f</mi></msub><mi>i</mi><mi>e</mi><mi>l</mi><msub><mi>d</mi><mi>n</mi></msub><mi>a</mi><mi>m</mi><mi>e</mi><mostretchy="false">(</mo></mrow><annotationencoding="application/xtex">field=mysqlfieldname(</annotation></semantics></math></span><spanclass="katexhtml"ariahidden="true"><spanclass="base"><spanclass="strut"style="height:0.8889em;verticalalign:0.1944em;"></span><spanclass="mordmathnormal"style="marginright:0.10764em;">f</span><spanclass="mordmathnormal">i</span><spanclass="mordmathnormal">e</span><spanclass="mordmathnormal"style="marginright:0.01968em;">l</span><spanclass="mordmathnormal">d</span><spanclass="mspace"style="marginright:0.2778em;"></span><spanclass="mrel">=</span><spanclass="mspace"style="marginright:0.2778em;"></span></span><spanclass="base"><spanclass="strut"style="height:1.0361em;verticalalign:0.2861em;"></span><spanclass="mordmathnormal">m</span><spanclass="mordmathnormal">ys</span><spanclass="mordmathnormal"style="marginright:0.03588em;">q</span><spanclass="mord"><spanclass="mordmathnormal"style="marginright:0.01968em;">l</span><spanclass="msupsub"><spanclass="vlisttvlistt2"><spanclass="vlistr"><spanclass="vlist"style="height:0.3361em;"><spanstyle="top:2.55em;marginleft:0.0197em;marginright:0.05em;"><spanclass="pstrut"style="height:2.7em;"></span><spanclass="sizingresetsize6size3mtight"><spanclass="mordmathnormalmtight"style="marginright:0.10764em;">f</span></span></span></span><spanclass="vlists"></span></span><spanclass="vlistr"><spanclass="vlist"style="height:0.2861em;"><span></span></span></span></span></span></span><spanclass="mordmathnormal">i</span><spanclass="mordmathnormal">e</span><spanclass="mordmathnormal"style="marginright:0.01968em;">l</span><spanclass="mord"><spanclass="mordmathnormal">d</span><spanclass="msupsub"><spanclass="vlisttvlistt2"><spanclass="vlistr"><spanclass="vlist"style="height:0.1514em;"><spanstyle="top:2.55em;marginleft:0em;marginright:0.05em;"><spanclass="pstrut"style="height:2.7em;"></span><spanclass="sizingresetsize6size3mtight"><spanclass="mordmathnormalmtight">n</span></span></span></span><spanclass="vlists"></span></span><spanclass="vlistr"><spanclass="vlist"style="height:0.15em;"><span></span></span></span></span></span></span><spanclass="mordmathnormal">am</span><spanclass="mordmathnormal">e</span><spanclass="mopen">(</span></span></span></span>result,i);

echo

"$table: $field\n";
}?>`

Notes

Note:

For backward compatibility, the following deprecated alias may be used: mysql_fieldtable()

Found A Problem?

There are no user contributed notes for this page.