How would I check to see if the values returned from an sql query are empty? I tried using if(empty($var)), but that didnt work either. heres my code
PHP Code:
while($row = mysql_fetch_array($Result))
{
if(count($row) == 0)
{
....
}
}
How would i check to see if $row is empty?
This is the right way to do this, you can check if the results are empty by finding number of row in returned results. There is a function in sql to do this mysql_num_rows
. Here is the method to use it:
if (mysql_num_rows($Result) == 0) {
//results are empty, do something here
} else {
while($admin_row = mysql_fetch_array($Result)) {
//processing when you have some data
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With