下面我们是测试一个php批量增加城市的代码以|分开哦。
function addtype()
{
if( $_files ){exit;}
$info ='';
$cityname = trim(postget('cityname',1));
$citytype = trim(postget('citytype',1));
$orderid = trim(postget('orderid',1));
if( $cityname ==0 || !is_numeric( $cityname ) )
{
message('请选择城市');
}
elseif(strlen($citytype) {
message('输入城市地区');
}
elseif( !is_numeric($orderid ))
{
message('对不起,排序必须是数字哦!');
}
if( strpos($citytype,'|')!=false)
{
$array = explode('|',$citytype);
if( is_array( $array ) )
{
$array = array_filter($array,'filter');
}
}
else
{
$array = $citytype;
}
$db= new db();
$d =date(y-m-d);
if( is_array( $array ) )
{
foreach( $array as $v => $_v )
{
$row = $db->query(select * from 111cn_city where upid=$cityname and cntitle=.$_v.);
if( $db->rows( $row ) )
{
$info.=$_v.',';
}
else
{
try{
$db->query(insert into 111cn_city(cntitle,upid,orderid,createdate)values('$_v',$cityname,'$orderid','$d'));
}catch (exception $e){
message('操作失败!');
}
}
}
message(增加成功,失败有$info,'addtype.php');
}
else
{
$query = $db->query(select * from 111cn_city where upid=$cityname and cntitle=$array);
if( $db->rows( $query ) )
{
message(对不起,你所要增加的城市[$array]己存在数据库了);
}
else
{
try{
$db->query(insert into 111cn_city(cntitle,upid,orderid,createdate)values('$array',$cityname,'$orderid','$d'));
message('操作成功','addtype.php');
}catch (exception $e){
message('失败成功');
}
}
}
}
本站原创转载注明 www.111cn.cn
http://www.bkjia.com/phpjc/445023.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/445023.htmltecharticlephp 批量增加数据 下面我们是测试一个php批量增加城市的代码以|分开哦。 function addtype() { if( $_files ){exit;} $info =''; $cityname = trim(postget('city...
