I've a range of IP addresses which i use with in_array to deny folks the next code.

$deny = array("111.222.333.444","999.555.444.222");
if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) {
header("location: http://google.com/");

Can there be an alternative choice to in_array utilizing a database. If I've got a database of IP addresses how do i look into the database for that Ip and redirect while using header?

Presuming MySQLi:

$query = "SELECT count(*) AS denied
          FROM table_of_ips
          WHERE ip = '".mysqli_real_escape_string($link, $_SERVER['REMOTE_ADDR'])."'
          LIMIT 1";
$result = mysqli_fetch_assoc(mysqli_query($link, $query));

if ($result['denied']) {
  header("location: http://google.com/");

Essentially, just Choose in which the IP matches the customer IP, when you get an effect, it's refused.

Are you currently searching for something similar to this?

SELECT ip_address FROM deny_table WHERE ip_address IN ('111.222.333.444','999.555.444.222');