批量增加主题分类及开启功能

scofone查看全部>> 03-03

人气 1,546

亲们该页面内会员们分享的“作品”,版权为才华横溢的原作者们所有滴,不得商业使用!

主要针对两张表进行操作,分别为:pre_forum_forumfield,与pre_forum_threadclass,其中pre_forum_threadclass为分类的信息表。

pre_forum_threadclass表:

fid=板块编号

name=主题分类的名称
displayorder=排列顺序
icon=图片地址

pre_forum_forumfield表中threadtypes存储为一个序列,即将序列修改即可。

序列为:

a:5:{i:0;s:0:"";i:1;s:0:"";s:7:"message";s:0:"";s:5:"medal";N;s:5:"users";s:0:"";},,,a:6:{s:8:"required";b:0;s:8:"listable";b:0;s:6:"prefix";s:1:"0";s:5:"types";a:5:{i:570;s:10:"教育看点";i:571;s:6:"校园黑板报";i:572;s:8:"名师堂";i:573;s:6:"校园之星";i:574;s::"小记者";}s:5:"icons";a:5:{i:570;s:0:"";i:571;s:0:"";i:572;s:0:"";i:573;s:0:"";i:574;s:0:"";}s:10:"moderators";a:5:{i:570;s:1:"1";i:571;s:1:"1";i:572;s:1:"1";i:573;s:1:"1";i:574;s:1:"1";}}

只需要将红色文字三段替换即可。

<?php

require("mysql_db_connect.php");

$arr=array(788,519,521,522,185,186,187,164,165,166,167,168,643,667,668,669,670,671,672,673,659,660,661,662,663,664,665,666,188,189,190,200,201,202,203,204,205,573,572,571,570,574,575,578,577,576,38,39,40,41,44,121,301,302,303,304,305,306,307,308,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,411);

$arr1=array('教育看点','校园黑板报','名师堂','校园之星','小记者');
$arr2=array(8,10,6,8,6);
for($i=0;$i<count($arr);$i++){
mysql_query("insert into pre_forum_threadclass (fid,name,icon,displayorder,moderators) values ($arr[$i],'$arr1[$j]','',$k,1)");
$sql="select typeid,name from pre_forum_threadclass where fid=$arr[$i] order by displayorder";
$s1=$s2=$s3="";
$t1=mysql_query($sql);
$k=0;
$t='a:6:{s:8:"required";b:0;s:8:"listable";b:0;s:6:"prefix";s:1:"0";s:5:"types";a:5:{str1}s:5:"icons";a:5:{str2}s:10:"moderators";a:5:{str3}}';
while ($rs = mysql_fetch_array($t1)){
$s1.="i:".$rs['typeid'].";s:".$arr2[$k].":"".$rs['name']."";";
$s2.="i:".$rs['typeid'].";s:0:"";";
$s3.="i:".$rs['typeid'].";s:1:"1";";
$k++;
}

$t=str_replace("str3",$s3,str_replace("str2",$s2,str_replace("str1",$s1,$t)));

$sql="update pre_forum_forumfield set threadtypes='$t' where fid=$arr[$i];<br>";

mysql_query($sql);

}
?>

标签
相关作品
批量增加主题分类及开启功能:等您坐沙发呢!



会员登陆还没有账号 立即注册

用户登录

忘记密码 ?

用第三方帐号直接登录

微博账号登陆 QQ账号登陆