您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php 批量增加数据_PHP教程

2024/6/19 15:17:34发布25次查看
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
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...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product