fix the example, per user note

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@244460 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Nuno Lopes 2007-10-19 12:05:59 +00:00
parent 1f7e9bb0ff
commit 75f80d3b87

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- $Revision: 1.9 $ -->
<refentry xml:id="function.mysql-field-table" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>mysql_field_table</refname>
@ -43,15 +43,20 @@
<programlisting role="php">
<![CDATA[
<?php
$result = mysql_query("SELECT name,comment FROM people,comments");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
$query = "SELECT account.*, country.* FROM account, country WHERE country.name = 'Portugal' AND account.country_id = country.id";
// get the result from the DB
$result = mysql_query($query);
// Lists the table name and then the field name
for ($i = 0; $i < mysql_num_fields($result); ++$i) {
$table = mysql_field_table($result, $i);
$field = mysql_field_name($result, $i);
echo "$table: $field\n";
}
// Assuming name is in the people table
$table = mysql_field_table($result, 'name');
echo $table; // people
?>
]]>
</programlisting>