Simple IP logging script

I just found this:


mysql_query("INSERT INTO IpLogs (Ip) VALUES ('$ip')") or die(mysql_error());
echo '<br>IP logged.';

But now I need to know how to do that if statement to see if the IP is already in the DB:

if ip is in db {
echo “its there”;
} else {
echo “it’s not”;