I am trying to create this simple if statement, but I am running into issues with the variable $testnumrows
. In this if condition I am trying to see if there are any group
columns with data and if so echo the amount of rows, but I want nothing to show up if there isn't.
In my db I have 6 rows that have what I mentioned in the query. The output that is showing up on the page is 0 though, so it seems my variable is being reset.
Before I had this:
$testnumrows = mysqli_num_rows($test);
echo " " . $testnumrows;
and it read the 6, I just can't get the if statement to work.
Here is the full code now.
<?php
$con = mysqli_connect("localhost", "", "", "");
$test = mysqli_query($con,"SELECT `group` FROM user_requests WHERE `group` = 1");
$testnumrows = mysqli_num_rows($test);
if($testnumrows = 0) {
echo "";
} else {
echo " " . $testnumrows;
}
?>