PHP mysqli_fetch_lengths() 函数

PHP 教程 · 2019-01-27 21:43:25

返回结果集中的字段长度:

<?php 
// 假定数据库用户名:root,密码:123456,数据库:CODERCTO 
$con=mysqli_connect("localhost","root","123456","CODERCTO"); 
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))
{
    $row=mysqli_fetch_row($result);
    
    // 显示字段长度
    foreach (mysqli_fetch_lengths($result) as $i=>$val)
    {
        printf("字段 %2d 长度为: %2d",$i+1,$val);
        echo "<br>";
    }
    
    // 释放结果集
    mysqli_free_result($result);
}

mysqli_close($con);
?>

定义和用法

mysqli_fetch_lengths() 函数返回结果集中的字段长度。

语法

mysqli_fetch_lengths(result);

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

技术细节

返回值: 如果整数表示每个字段(列)的长度则返回数组,如果发生错误则返回 FALSE。
PHP 版本: 5+

点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html

查看所有标签

Computational Advertising

Computational Advertising

by Kushal Dave、Vasudeva Varma / Now Publishers Inc / 2014

Computational Advertising (CA), popularly known as online advertising or Web advertising, refers to finding the most relevant ads matching a particular context on the Web. The context depends on the t......一起来看看 《Computational Advertising》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具