Facts You want to Know About Use Of Mysqli_num_rows() Function

I want to share a situation where I better know about mysqli_num_rows() function.
At the time of developing login functionality, this function is very useful.
When you create code or write a query for as like,

$query = mysqli_query($connection_variable, "SELECT username, password FROM user WHERE username = '$username' AND password = '$password' ");

On this code or query, we give attention to some things like,

  1. On WHERE clause condition all posted variable which is in “$” notation write within in Single Quote (‘ ‘).
  2. If you use “mysqli” always remember it takes 2 parameters,
    Ist: Connection variable
    IInd: Query or query variable

After this query you think your login functionality is working fine if you test you get the result like all works but if you use some redirection after the query is true then,

You test with the wrong credentials till the code redirects to that page because the query is running correctly.

So for this problem we use “mysqli_num_rows()” function, this function check after running the query, how many rows of data we get.

If query didn’t get any row then your code not redirected to the page and you login functionality working great..!

In code, you check like this

if(mysqli_num_rows($query)>0){}

//returns the number of rows


Was this article helpful?
YesNo
My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH, my native place in Odisha. I am a Web Programmer by profession and working on more than 50 projects to date. My passion is working on the web-based project using PHP and relate to all CMS and frameworks which is based on PHP.
Posts created 175

3 thoughts on “Facts You want to Know About Use Of Mysqli_num_rows() Function

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top
mariobet - supertotobet - escort -

takip7.com

- milanobet giriş - gizabet giriş -
perabet giriş
- betkanyon giriş -

jojobet giriş

We are now accepting guest posting and creation of back-links.
This is default text for notification bar