Something like this??? You can change your query depending on how all the URLs in the database are stored.
$url_parts=parse_url($url);
$domain=strtolower(str_replace('www.', '', $url_parts['host']));
$query=mysqli_query($dbconn, "SELECT column_name FROM table WHERE
INSTR(LOWER(url_column_name), '$domain')");