[英]php mysql loop insert IP Address block
How can I insert 256 IP based on /24 block. 如何插入基于/ 24块的256 IP。 if IP block is 192.168.1.0/24 & network is 192.168.1.0 so I want to create a loop to insert
192.168.1.0
to 192.168.1.255
in mysql table . 如果IP块是192.168.1.0/24且网络是192.168.1.0,那么我想创建一个循环以在mysql表中插入
192.168.1.0
到192.168.1.255
。 there will be a button when i press that it will insert 256 row 0 to 255.. Please help me to do it in php mysql 当我按它会插入256行0到255时会有一个按钮。请帮助我在php mysql中做到这一点
if (isset ( $_POST ['doSubmit'] ) && $_POST ['doSubmit'] == 'Submit Details') {
// Filter POST data for harmful code (sanitize)
foreach ( $_POST as $key => $value ) {
$data [$key] = filter ( $value );
}
$network = $data [network]; // Is network ip 192.168.1.0
// Action will go here
}
so i want to create a loop to insert 192.168.1.0 to 192.168.1.255 in mysql table
所以我想创建一个循环在mysql表中插入192.168.1.0到192.168.1.255
Generate like this... 这样生成...
foreach(range(0,255) as $val)
{
$arr[]="192.168.1.".$val;
//Running a query 255 times here is not a good idea !
}
//$arr now holds all your IPs , you could push it into your SQL Query..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.