全部博文(921)
分类:
2007-04-13 19:57:34
程序写的比较烂,请大家不要见笑…………
mssql_connect("(local)","sa","421129");//连接ms sql服务器
mssql_select_db("makecan");//链接数据库
$result = mssql_query("select * from news order by ID DESC ");
include_once('./include/main.inc.php');//直接使用x—space 配置文件
include_once("./include/common.inc.php");//同上
//$row = mssql_fetch_array($result);
$i = 0;
$myrow =mssql_fetch_assoc($row);
//将ms sql表中如 2007 四月 9 0:00 变态得时间格式转化为unix时间戳……
while($row = mssql_fetch_array($result)){
$date = explode(" ",$row['PutDate']);
switch($date[2]) {
case '一月':
$month = 1;
case '二月':
$month = 2;
case '三月':
$month = 3;
case '四月':
$month = 4;
case '五月':
$month = 5;
case '六月':
$month = 6;
case '七月':
$month = 7;
case '八月':
$month = 8;
case '九月':
$month = 9;
case '十月':
$month = 10;
case '十一月':
$month = 11;
case '十二月':
$month = 12;
}
$dateline = mktime(0,0,0,$month,$date[2],$date[0]);
//不同得数据库中多个类别得id 整合起来……不知道怎么表达^_^…………
if($row['Sort'] == 1)
$catid = 75;
elseif($row['Sort'] == 2)
$catid = 1;
elseif($row['Sort'] == 3)
$catid = 76;
elseif($row['Sort'] == 255)
$catid = 77;
$sql = "INSERT INTO `supe_spaceitems`(`catid`,`uid`,`username`,`type`,`subject`,`dateline`,`lastpost`)
VALUES('$catid','1','admin','news','".(addslashes($row['Title']))."','".$dateline."','".time()."')";
$resa = $_SGLOBAL['db']->query($sql);
$itemid = $_SGLOBAL['db']->insert_id();
$sql = "INSERT INTO `supe_spacenews`(`itemid`,`message`,`relativetags`,`customfieldid`,`customfieldtext`,`newsauthor`,`newsfrom`)
values('".$itemid."','".(addslashes($row['Content']))."','a:0:{}','2','a:0:{}','admin','".(addslashes($row['Source']))."')";
$resb = $_SGLOBAL['db']->query($sql);
$i++;
if(!$resa || !$resb){
echo "第".$i."条数据出错了!";
exit;
}
}
echo "恭喜您导入了".$i."条数据!!";
?>
看完了程序,欣赏美女心情更爽…………^_^…………