Mysqli_num_rows

Mysqlinumrows ($resultset) The input parameter $resultset is the output of result set identifier of mysqliquery , mysqlistoreresult or mysqliuseresult. The output is number of rows present in the result set. MySQLI database connection file. Mysqlinumrows ใน php programming เมื่อเราต้องการรู้จำนวนแถวข้อมูลหรือชุดข้อมูลที่ได้การ query จากฐานข้แอมูล หลายๆคนอาจจะใช้งานคำสั่ง COUNT ใน MySQL ซึงสามารถให้.

  • PHP Tutorial
  • Advanced PHP
  • PHP Form Examples
  • PHP login Examples
  • PHP AJAX Examples
  • PHP XML Example
Mysqli_num_rows
  • PHP Frame Works
  • PHP Design Patterns
Mysqli_num_rows
  • PHP Function Reference
  • PHP Useful Resources
  • Selected Reading

Definition and Usage

A PHP result object (of the class mysqli_result) represents the MySQL result, returned by the SELECT or, DESCRIBE or, EXPLAIN queries.

The mysqli_num_rows() function accepts a result object as a parameter, retrieves the number of rows in the given result.

Syntax

Mysqli_num_rows

Parameters

Sr.NoParameter & Description
1

result(Mandatory)

This is an identifier representing a result object.

Return Values

The PHP mysqli_num_rows() function returns an integer value representing the number of rows/records in the given result object.

Mysqli_num_rows Tutorials

PHP Version

This function was first introduced in PHP Version 5 and works works in all the later versions.

Example

Following example demonstrates the usage of the mysqli_num_rows() function (in procedural style) −

Mysqli_num_rows Returns 0

This will produce following result −

Example

In object oriented style the syntax of this function is $result->num_rows; Following is the example of this function in object oriented style $minus;

Mysqli_num_rows(false) #1 Main Thrown In

This will produce following result −

<?php
$link
= mysqli_connect('localhost', 'my_user', 'my_password', 'world');
/* verificar la conexión */
if (mysqli_connect_errno()) {
printf('Conexión fallida: %sn', mysqli_connect_error());
exit();
}
if (
$result = mysqli_query($link, 'SELECT Code, Name FROM Country ORDER BY Name')) {
/* determinar el número de filas del resultado */
$row_cnt = mysqli_num_rows($result);
printf('El resultado tiene %d filas.n', $row_cnt);
/* cerrar el resulset */
mysqli_free_result($result);
}
/* cerrar la conexión */
mysqli_close($link);
?>