<?
include "../inc/config.php";
include "../../inc/inc.php";
if($_POST['F_typeid'])
{
$sql = "select id,ctid from newstype where id=".$_POST['F_typeid'];
$rs = mysql_query($sql);
$row = mysql_fetch_array($rs);
$typeid = $row['id'];
$ctid = $row['ctid'];
foreach($_POST['del'] as $del)
{
$c = "";
$val = "";
$sql = "select * from news where id=$del";
//echo $sql."<br>";
$rs = mysql_query($sql);
$row = mysql_fetch_assoc($rs);
$row['typeid'] = $typeid;
$row['ctid'] = $ctid;
$row['name8'] = str_replace('"','\"',$row['name8']);
array_shift ($row);
foreach($row as $cc=>$dd)
{
$c .= $cc.",";
$dd = str_replace('"','\"',$dd);
$dd = str_replace("'","\'",$dd);
$val .= "'".$dd."',";
}
$c = substr($c,0,-1);
$val = substr($val,0,-1);
$sql = "select count(*) from news where title='".$row['title']."' and typeid=$typeid and ctid=$ctid";
//echo $sql."<br>";
$rs = mysql_query($sql);
$row = mysql_fetch_array($rs);
if($row[0]==0)
{
$sql = "insert into news (".$c.") values(".$val.")";
//echo $sql."<br>";exit;
$result=mysql_query($sql) or die(mysql_error());
}else
{
$result = 1;
}
}
}
if($result){
//页面跳转
$url=$_SERVER['HTTP_REFERER'];
echo "<SCRIPT LANGUAGE='Javascript'>";
echo "location.href='$url'";
echo "</SCRIPT>";
}
else{
echo $eor;
}
?>