PHP | mysqli_num_rows() Function Last Updated : 31 Jul, 2021 Comments Improve Suggest changes Like Article Like Report The mysqli_num_rows() function is an inbuilt function in PHP which is used to return the number of rows present in the result set. It is generally used to check if data is present in the database or not. To use this function, it is mandatory to first set up the connection with the MySQL database. Syntax: mysqli_num_rows ( $result ); Parameters: This function accepts single parameter $result (where $result is a MySQL query set up using mysqli_query()). It is a mandatory parameter and represents the result set returned by a fetch query in MySQL. Return Value: It returns the number of rows present in a result set. If no rows match the given criteria then it returns false instead. Consider there is a table named geek in a MySQL database named Geeks. Below is the description of the table geek. Username Password Geek1 Pass1 Geek2 Pass2 Geek3 Pass3 Geek4 Pass4 Below programs illustrate the mysqli_num_rows() function in PHP. php <?php // Setting up connection with database Geeks $connection = mysqli_connect("localhost", "root", "", "Geeks"); // Check connection if (mysqli_connect_errno()) { echo "Database connection failed."; } // query to fetch Username and Password from // the table geek $query = "SELECT Username, Password FROM geek"; // Execute the query and store the result set $result = mysqli_query($connection, $query); if ($result) { // it return number of rows in the table. $row = mysqli_num_rows($result); if ($row) { printf("Number of row in the table : " . $row); } // close the result. mysqli_free_result($result); } // Connection close mysqli_close($connection); ?> Output: Number of row in the table : 4 PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples. Comment More infoAdvertise with us Next Article PHP | mysqli_num_rows() Function R RahulUniyal Follow Improve Article Tags : Web Technologies PHP Similar Reads PHP | mysqli_ping() Function The mysqli_ping() function is used to ping a server connection. That is it is used to check if a host is reachable on an IP network or not. This function also tries to reconnect if an existing server connection is lost. To use this function, it is mandatory to first set up the connection with the My 2 min read PHP min( ) Function The min() function of PHP is used to find the lowest value in an array, or the lowest value of several specified values. The min() function can take an array or several numbers as an argument and return the numerically minimum value among the passed parameters. The return type is not fixed, it can b 2 min read PHP | mysqli_error() Function The mysqli_error() function is used to return the error in the most recent MySQL function call that failed. If there are multiple MySQL function calls, the error in the last statement is the one that is pointed out by the function. Syntax: mysqli_error("database_name") Parameters: This function acce 1 min read PHP | mysqli_close() Function MySQLi Procedural procedure: To close the connection in mysql database we use php function mysqli_close() which disconnect from database. It require a parameter which is a connection returned by the mysql_connect function. Syntax: mysqli_close(conn); If the parameter is not specified in mysqli_close 2 min read PHP mysqli_connect() Function The mysqli_connect() function in PHP is a fundamental tool for establishing a connection to a MySQL database. This function is crucial for PHP applications that need to interact with MySQL databases, enabling them to execute queries, retrieve data, and perform various database operations.In this art 3 min read PHP pos() Function The pos() is an inbuilt function in PHP which is used to return the value of the element in an array which the internal pointer is currently pointing to. The pos() function does not increment or decrement the internal pointer after returning the value. In PHP all arrays have an internal pointer. Thi 2 min read PHP | mysqli_real_escape_string() Function The mysqli_real_escape_string() function is an inbuilt function in PHP which is used to escape all special characters for use in an SQL query. It is used before inserting a string in a database, as it removes any special characters that may interfere with the query operations. When simple strings ar 2 min read PHP list() Function The list() function is an inbuilt function in PHP which is used to assign array values to multiple variables at a time. This function will only work on numerical arrays. When the array is assigned to multiple values, then the first element in the array is assigned to the first variable, second to th 2 min read PHP is_long() Function The is_long() function is an inbuilt function in PHP that is used to check whether the given value is a long integer or not. Syntax: bool is_long(mixed $value) Parameters: This function accepts a single parameter $value that holds the value which needs to check for a long integer. Return Value: This 1 min read PHP | mysqli_fetch_array() Function The mysqli_fetch_array() function is used to fetch rows from the database and store them as an array. The array can be fetched as an associative array, as a numeric array or both. Associative arrays are the arrays where the indexes are the names of the individual columns of the table. On the other h 2 min read Like