Hey everybody I want to let you know that I have undertaken the grueling task of getting the heck away from WordPress. I was so sick of the problems and updates I had to do all the time. I am now using my ezbloo system and I am integrating all my old posts into the new system. It sucks, but in the end, I will save bundles of time. I needed to keep things simple and that is why I created ezbloo. I'll have more on this later for you guys after I am done with the total integration of my old posts here. So if you are looking for a post and need it faster, shoot me an email and I will make it a priority. [email protected]

There are many times when you have to PHP MySqli Check For No Results in Database. Maybe you are checking the username and password of a user and match it to an authenticated user.

Prerequisites for PHP MySqli Check For No Results in Database

In order to perform this query you will have to have something in your database to  compare it to. We are going to compare our form variables to what we have in the database. Make sure that you have the following.

Retrieve Information From A Database And Compare

Here is the code to retrieve information from a database. I included a sample form in this code for you. The important thing to note is that we are using the num_rows; function that comes with PHP. This will tell us if there were no rows that matched the criteria.
<?php include('config.php'); 
if(isset($_POST['submit'])){

$comparethis=$_POST['compare'];
$result = $con->query("SELECT * FROM TABLE WHERE something='$comparethis'") ;

$rowcount = $result->num_rows;

if($rowcount < 1){
echo 'There is no record that matches that';
die()
}

while ($row = $result->fetch_assoc()) {
echo $row['row-name'];
}

$con-> close();
}
?></pre>
<form action="" method="post">
<input name="compare" type="text" />
<input name="submit" type="submit" value="submit" />
</form>
<pre>