【www.gdgbn.com--mysql教程】

dedecms批量增加栏目分类方法
这是我自己写的一款指导导入分类的方法,由于某种原因要几百个分类,如果增加太麻烦了,所以就写了一个简单的。*/

$cn = mysql教程_connect("localhost","root","root");
mysql_select_db("aa",$cn);
mysql_query("set names "gb2312"");

$str = strtolower("");
$array = explode(",",$str);
/*print_r( $array );
exit;*/

for( $i=0;$i< count( $array ) ;$i++ )
{
 $select = "select * from 3g_arctype where typename="".$array[$i].""";
 $query = mysql_query( $select ) or die( mysql_error());
 if( !mysql_num_rows( $query ) )
 {
  $sql ="insert into `3g_arctype` (
`reid` ,
`topid` ,
`sortrank` ,
`typename` ,
`typedir` ,
`isdefault` ,
`defaultname` ,
`issend` ,
`channeltype` ,
`maxpage` ,
`ispart` ,
`corank` ,
`tempindex` ,
`templist` ,
`temparticle` ,
`namerule` ,
`namerule2` ,
`modname` ,
`description` ,
`keywords` ,
`seo教程title` ,
`moresite` ,
`sitepath` ,
`siteurl` ,
`ishidden` ,
`cross` ,
`crossid` ,
`content` ,
`smalltypes`
)
values (
 "3", "3", "50", "".$array[$i]."", "/xx/".$array[$i]."", "1", "index.html", "1", "3", "-1", "0", "0", "{style}/index_soft.htm", "zhuti/list.html", "zhuti/page.html", "{typedir}/{aid}.html", "{typedir}/list_{tid}_{page}.html", "default", "", "0", "", "0", "", "", "0", "0", null , null , null
);";
  
  if( mysql_query( $sql ) )
  {
   echo "".$array[$i]."导入成功
";
  }
  else
  {
   echo $array[$i]."导入失败原因".mysql_error()."
";
   echo $sql;
   exit;
  }
 
 }
 else
 {
  echo "存在记录".$array[$i]."
";
 }
}

本文来源:http://www.gdgbn.com/shujuku/29438/