<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Topic extends CI_Controller {

	function __construct(){
		parent::__construct();
        	$this->load->helper('url');
        	$this->load->helper('form');
                $this->load->library('session'); //加载session
		$this->load->model('CsdjDB');
		$this->load->model('CsdjAdmin');
	        $this->CsdjAdmin->Admin_Login();
	}


	public function save()
	{
	    $sid = $this->input->get('sid');
	    $id = $this->input->get('id');

            $sqlstr="select * from ".CS_SqlPrefix."topic where CS_SID=".$sid." order by CS_ID desc";
	    $result=$this->CsdjDB->db->query($sqlstr);
	    $data['topic'] = $result->result();
	    $data['ids'] = $id;
	    $data['sid'] = $sid;
            $this->load->view('admin/zj_save',$data);
        }

	public function saveedit()
	{
            $this->CsdjAdmin->Admin_Qx('8');
	    $tid = $this->input->post('ZTID');
	    $id = $this->input->post('id');
	    $sid = $this->input->post('sid');
            if($sid==3){
                 $this->db->query("update ".CS_SqlPrefix."vod set CS_TID=".$tid." where cs_id in(".$id.")");
            }else if($sid==2){
                 $this->db->query("update ".CS_SqlPrefix."news set CS_TID=".$tid." where cs_id in(".$id.")");
            }else{
                 $this->db->query("update ".CS_SqlPrefix."dance set CS_TID=".$tid." where cs_id in(".$id.")");
            }
            echo '<script>
                        alert("恭喜您，操作成功！");
                        parent.document.location.reload();
                 </script>';
        }
}

