Jump to content

if statement not working


MDanz

Recommended Posts

$user = mysql_query("SELECT * FROM Users WHERE username LIKE '$letter%' ORDER BY username")or die (mysql_error()); 

$num_rows = mysql_num_rows($user);



if ($num_rows == "0")
{
echo "<font face='Courier New' font size=5px font color=#FF9900>$letter</font><br /><br />";

echo "<font face='Courier New' font size=3px font color=#FBB917>No Users</font><br>";
}

else 
{
echo "<font face='Courier New' font size=5px font color=#FF9900>$letter</font><br /><br />";

echo "<font face='Courier New' font size=3px font color=#FBB917><a href='ustack.php?search=$username&submit=Go!' style='text-decoration: none';>$username</a></font><br>";
}

 

 

this isn't working now that i've added the if statement..??

Link to comment
https://forums.phpfreaks.com/topic/185291-if-statement-not-working/
Share on other sites

mysql_num_rows returns an integer not a string, therefore it returns 0, not "0". Having said that I'd have thought == evaluates them as the same. But I don't know as I haven't tested it. You will really need to be more specific as to what exactly "if statement not working" means.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.