php 批量增加数据
下面我们是测试一个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
网趣购物系统静态版支持网站一键静态生成,采用动态进度条模式生成静态,生成过程更加清晰明确,商品管理上增加淘宝数据包导入功能,与淘宝数据同步更新!采用领先的AJAX+XML相融技术,速度更快更高效!系统进行了大量的实用性更新,如优化核心算法、增加商品图片批量上传、谷歌地图浏览插入等,静态版独特的生成算法技术使静态生成过程可随意掌控,从而可以大大减轻服务器的负担,结合多种强大的SEO优化方式于一体,使










