PHP mysqli_num_rows() 函數
PHP mysqli_num_rows() 函數
返回結果集中行的數量:
<?php // 假定數據庫用戶名:root,密碼:123456,數據庫:RUNOOB $con=mysqli_connect("localhost","root","123456","RUNOOB"); 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 運算符
- PHP Switch 語句
- PHP 命名空間 namespace
- PHP array_chunk() 函數
- PHP array_combine() 函數
- PHP array_count_values() 函數
- PHP array_flip() 函數
- PHP array_intersect_uassoc() 函數
- PHP array_pop() 函數
- PHP array_push() 函數
- PHP array_splice() 函數
- PHP array_uintersect_uassoc() 函數
- PHP compact() 函數
- PHP end() 函數
- PHP next() 函數
- PHP pos() 函數
- PHP prev() 函數
- PHP 5 Calendar 函數
- PHP Filter 函數
- PHP 5 Math 函數