Php adds data in batches. Below we will test the code for adding cities in php in batches to add data in batches. FunctionAddtype () {if ($ _ FILES) {exit;} $ info; $ citynametrim (PostGet (city php batch add data
Next we will test a php code to add cities in batches and separate them with "|.
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 ('select a city ');
}
Elseif (strlen ($ citytype) <2)
{
MessAge ('input City Region ');
}
Elseif (! Is_numeric ($ orderid ))
{
MessAge ('sorry, the order must be a number! ');
}
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 ('Operation failed! ');
}
}
}
MessAge ("added successfully, failed $ info", 'addtype. php ');
}
Else
{
$ Query = $ Db-> query ("select * from 111cn_city where upid = $ cityname and cntitle =" $ array "");
If ($ Db-> rows ($ Query ))
{
MessAge ("Sorry, the city [$ array] you want to add already has a database ");
}
Else
{
Try {
$ Db-> query ("Insert into 111cn_city (cntitle, upid, orderid, createdate) values ('$ array', $ cityname,' $ orderid', '$ d ') ");
MessAge ('Operation succeeded ', 'addtype. php ');
} Catch (Exception $ e ){
MessAge ('failed successfully ');
}
}
}
}
Original site reprinted with www.111cn.cn
Http://www.bkjia.com/PHPjc/445023.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445023.htmlTechArticlephp batch increase data below we are testing a php batch increase city code to | separate Oh. Function Addtype () {if ($ _ FILES) {exit;} $ info = ''; $ cityname = trim (PostGet ('City...