Welcome to Techno Smarter QA, Question, Answer forum. Ask questions, receive answers, or help someone. Join Now
Welcome to Techno Smarter Q&A, where you can ask questions and receive answers from other members of the community. Ask the Technical & Programming related questions that you want. Join our community and help others .
+2 votes
in PHP by (9.1k points) 11 25 63

3 Answers

+2 votes

The total number of rows count using PHP and MySQL .you can count using two methods. First of all, you can use count() function. You have to need to define the count() function under the MySQL query.

$sql="select count('1') from users";

  We have used = count(1) function also we can use count(*) replace count(1) because. COUNT(*) counts the number of rows. Since both 0 and 1 are non-null values, COUNT(0)=COUNT(1) and they both will be equivalent to the number of rows COUNT(*). That is a different concept, but the result produce will be the same

The second method - 

In the second method, you count the MySQL table rows using 

mysqli_num_rows(); function   . 

mysqli_num_rows(); function helps you count the mysql table rows . 


by (9.1k points) 11 25 63
+1 vote
Count mysql table rows using count() function .

Create a database table and insert some data into the database and use count() function that helps to count the rows of database table . You can echo the table rows number .
by (7.2k points) 13 29 62
Thanks for sharing the valuable answer.
+1 vote

Hope it will help. 

$sql="select count('*') from users";


$mysqliStatus = $mysqli->query($sql);

$rows_count_value = mysqli_num_rows($mysqliStatus);

 echo $rows_count_value; 

by (1.4k points) 2 5
reshown by