Note Submitter: PoMdaPiMp
----
In the official example, there is a mistake.
<?php
[...]
$table = mysql_field_table($result, 'name');
[...]
?>
The last argument is here a string and not the integer
expected by the function.
Indeed, in the synopsis, the two arguments' types are :
result and integer.
Here is an other little example that corrects the mistake
and give another use of the function.
<?php
// Build a very easy request
$query = "SELECT account.*, country.* FROM account,
country WHERE country.name LIKE '%france%' AND
account.country_id = country.id";
// Gets the result from the DB
$result = mysql_query($query);
// Lists the table name and then the field name
for ($x = 0; $x < mysql_num_fields($result); $x++)
{
$str = mysql_field_name($result, $x);
print ('<b>' . mysql_field_table($result, $x) .
'</b>: ' . $str . '<br />');
}
?>
In this little code, the offset is given to mysql_field_name
as the second argument.
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|