PHP mysqli_field_tell()Functions
Get field information for all fields, then use mysqli_field_tell() to obtain the current field and output the field name, table, and maximum length:
<?php
// 假定数据库用户名:root,密码:123456,数据库:EXAMPLE
$con=mysqli_connect("localhost","root","123456","EXAMPLE");
if (mysqli_connect_errno($con))
{
echo "连接 MySQL 失败: " . mysqli_connect_error();
}
$sql="SELECT name,url FROM websites ORDER BY alexa";
if ($result=mysqli_query($con,$sql))
{
//获取所有字段信息
while ($fieldinfo=mysqli_fetch_field($result))
{
// 获取当前字段信息
$currentfield=mysqli_field_tell($result);
printf("列 %d", $currentfield);
echo "<br>";
printf("字段名: %s", $fieldinfo->name);
echo "<br>";
printf("表名: %s", $fieldinfo->table);
echo "<br>";
}
// 释放结果集
mysqli_free_result($result);
}
mysqli_close($con);
?>
Definition and Usage
The mysqli_field_tell() function returns the position of the field pointer.
Syntax
mysqli_field_tell(result);
| Parameters | Description |
|---|---|
| result | Required. Specifies the result set identifier returned by mysqli_query(), mysqli_store_result(), or mysqli_use_result(). |
Technical Details
| Return value: | Returns the current offset of the field pointer. |
|---|---|
| PHP Version: | 5+ |
PHP MySQLi Reference Manual Other Extensions