//变量$ stat_ip位于表Hasoffers中,如果它位于列值network_start_ip和network_end_ip之间,它将位于另一个名为Blacklisted的表中。我需要编写一个函数来帮助我做同样的事情通过访问所有三个。
<?php
include('adodb/adodb.inc.php');
mysql_connect("*****","***","***");
mysql_select_db("********");
$pl=mysql_query("SELECT stat_ip,stat_session_ip FROM Hasoffers");
$count=mysql_num_rows($pl)
while($row=mysql_fetch_array($pl))
{
$stat_ip=$row['stat_ip'];
echo fn($stat_ip)."<br>";
}
$bip=mysql_query("SELECT inet_aton(network_start_ip),inet_aton(network_end_ip) FROM blacklisted");
while($array=mysql_fetch_array($bip))
{
$start_ip=$array['network_Start_ip'];
$end_ip = $array['netwrok_end_ip'];
}
function fn($stat_ip)
{
$result =mysql_query('SELECT stat_ip FROM Hasoffers where ($stat_ip BETWEEN INET_ATON(network_start_ip) AND INET_ATON(network_end_ip)');
}
?>php
答案 0 :(得分:0)
您可以在
之间使用SELECT inet_aton(network_start_ip),inet_aton(network_end_ip)
FROM blacklisted
WHERE your_ip_column BETWEEN INET_ATON(network_start_ip) AND INET_ATON(network_end_ip)
如果您在单个选择中同时需要查询,则可以在
之间使用左连接SELECT a.stat_ip
FROM Hasoffers as a
LEFT JOIN blacklisted on as b on inet_aton(a.stat_ip)
between INET_ATON(b.network_start_ip) AND INET_ATON(b.network_end_ip)