PHP mysqli_num_rows() 函数

PHP 教程 · 2019-01-28 09:43:39

返回结果集中行的数量:

<?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))
{
    // 返回记录数
    $rowcount=mysqli_num_rows($result);
    printf("总共返回 %d 行数据。",$rowcount);
    // 释放结果集
    mysqli_free_result($result);
}


mysqli_close($con);
?>

定义和用法

mysqli_num_rows() 函数返回结果集中行的数量。

语法

mysqli_num_rows(result);

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

技术细节

返回值: 返回结果集中行的数量。
PHP 版本: 5+

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

查看所有标签

Python Machine Learning

Python Machine Learning

Sebastian Raschka / Packt Publishing - ebooks Account / 2015-9 / USD 44.99

About This Book Leverage Python' s most powerful open-source libraries for deep learning, data wrangling, and data visualization Learn effective strategies and best practices to improve and opti......一起来看看 《Python Machine Learning》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

SHA 加密
SHA 加密

SHA 加密工具

html转js在线工具
html转js在线工具

html转js在线工具