<? session_start();?>
<?php include("anti_sql2.php") ?>
<?php include("conn.php") ?>
<? 

$read_stuid=$_GET["stuid"];
$read_juan_id=$_GET["juan_id"];
$read_shiti_id=$_GET["id"];
$read_shititype=$_GET["shititype"];

?>



<? 

//------------------------****#1234# ----------
$getlist=array();
$new_id_str='';

$sql="select  *  from  cang ";
$sql=$sql."   where  stuid='".$read_stuid."'";
$sql=$sql."   and   juan_id=".$read_juan_id;

$rs=$conn->execute($sql);
$exist_cang_flag=0;
if (!$rs->EOF)
{
	$exist_cang_flag=1;
	if ($read_shititype==1)
	{
		$read_s_old_str=$rs->fields["test_ssele"];
	}
	if ($read_shititype==2)
	{
		$read_s_old_str=$rs->fields["test_dsele"];
	}
	if ($read_shititype==3)
	{
		$read_s_old_str=$rs->fields["test_tiankong"];
	}
	
	if ($read_shititype==4)
	{
		$read_s_old_str=$rs->fields["test_panduan"];
	}
	
	if ($read_shititype==5)
	{
		$read_s_old_str=$rs->fields["test_lunshu"];
	}
	
	
}
$rs->close;



if ($exist_cang_flag==1)   //存在记录---
{
	//更新-------------
	
	$getlist=explode("#",$read_s_old_str);
	$s_count=count($getlist);
	$s_id_exist=0;
	for($x=0;$x<$s_count;$x++)
	{
		if ($getlist[$x]==$read_shiti_id)  
		{
			$s_id_exist=1;
			//break;
			$getlist[$x]=0;
		}
	}
	
	for($x=0;$x<$s_count;$x++)
	{
		if ($getlist[$x]!=0)
		{
			$new_id_str=$new_id_str.$getlist[$x]."#"; 
		}
	}
	
	
	if ($s_id_exist==1)  //shiti_id 存在
	{
	    
		
		
		if ($read_shititype==1)
		{
			$sql="update  cang  set  test_ssele='".$new_id_str."'";
			$sql=$sql."   where  stuid='".$read_stuid."'";
			$sql=$sql."   and   juan_id=".$read_juan_id;
			$rs=$conn->execute($sql);
			$rs->close;
		}
		
		if ($read_shititype==2)
		{
			$sql="update  cang  set  test_dsele='".$new_id_str."'";
			$sql=$sql."   where  stuid='".$read_stuid."'";
			$sql=$sql."   and   juan_id=".$read_juan_id;
			$rs=$conn->execute($sql);
			$rs->close;
		}
		
		if ($read_shititype==3)
		{
			$sql="update  cang  set  test_tiankong='".$new_id_str."'";
			$sql=$sql."   where  stuid='".$read_stuid."'";
			$sql=$sql."   and   juan_id=".$read_juan_id;
			$rs=$conn->execute($sql);
			$rs->close;
		}
		if ($read_shititype==4)
		{
			$sql="update  cang  set  test_panduan='".$new_id_str."'";
			$sql=$sql."   where  stuid='".$read_stuid."'";
			$sql=$sql."   and   juan_id=".$read_juan_id;
			$rs=$conn->execute($sql);
			$rs->close;
		}
		
		if ($read_shititype==5)
		{
			$sql="update  cang  set  test_lunshu='".$new_id_str."'";
			$sql=$sql."   where  stuid='".$read_stuid."'";
			$sql=$sql."   and   juan_id=".$read_juan_id;
			$rs=$conn->execute($sql);
			$rs->close;
		}
		
		
	}
	
	
	
}

$targeturl="my_cang_shiti.php";
echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />";
echo "<body>";
echo "<script language=javascript>";
echo "window.location.href='$targeturl';";
echo "</script>";
echo "</body>";
     
	 




