Search database

I am having trouble with coding a search. Its very basic stuff. I want to search a table to get a match for $ips (which is an IP address).How do I write the if and else statement - one for where the ip address is in the table and another for when it is not

I have used the following code but there are no records in the table so it should not be found

$result = mysql_query("SELECT ip FROM ip WHERE ip='$ips'");

if (!$result) {
echo "Your ip address is accepted";
echo "your website is banned";

$res = mysql_query(sprintf("SELECT ip FROM table WHERE ip = '%s' LIMIT 1;", $ip));

if(1 === mysql_num_rows($res)){
  #ip found
  #ip not found


Thanks - that works

BTW what is the difference between === and ==

== compares value, === compares value and type.