Latest web development tutorials

PHP mysqli_field_tell () function

PHP MySQLi Reference Manual PHP MySQLi Reference Manual

Obtain field information for all fields, and then get through the current field mysqli_field_tell () and output field names, and the maximum length of the table:

<?php 
// 假定数据库用户名:root,密码:123456,数据库:w3big 
$con=mysqli_connect("localhost","root","123456","w3big"); 
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

() Function returns the position of the pointer field mysqli_field_tell.


grammar

mysqli_field_tell( result ) ;

参数 描述
result 必需。规定由 mysqli_query()、mysqli_store_result() 或 mysqli_use_result() 返回的结果集标识符。

technical details

return value: Returns the current offset pointer field.
PHP version: 5+


PHP MySQLi Reference Manual PHP MySQLi Reference Manual