<?php
@session_start();
include('checkstate.php');
 if(@$_GET['do']=='doadd'){
     $gradeid=$_POST['gradeid'];
     $languageid=$_POST['languageid'];
     $company=$_POST['company'];
     $url=$_POST['url'];
     $jsqid=$_POST['jsqid'];
	 $is=sql_select("select count(*) from custom where url='".$url."'");
	 if($is[0][0]==1){
	   echo "<script type='text/javascript'>alert('该网站已经添加');</script>";
	   echo "<script type=\"text/javascript\">window.location.href='allcompany.php';</script>";
	 }else{
	 $insert="insert into custom(gradeid,languageid,company,url,jsqid) value('".$gradeid."','".$languageid."','".$company."','".$url."','".$jsqid."')";
	 mysql_query($insert);
	 }
 }elseif(@$_GET['do']=='domod'){
     $id=$_POST['id'];
     $gradeid=$_POST['gradeid'];
     $languageid=$_POST['languageid'];
     $company=$_POST['company'];
     $url=$_POST['url'];
     $jsqid=$_POST['jsqid'];
	 $state=$_POST['state'];
	 
	 $update="update custom set gradeid='".$gradeid."',languageid='".$languageid."',company='".$company."',url='".$url."',jsqid='".$jsqid."',state='".$state."' where id=".$id;
	
	 mysql_query($update);
	 
 }
 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ETW国际案例演示</title>
<link rel="stylesheet" href="media/css.css" type="text/css" media="screen" />
</head>

<body>
<div id="main">
     <div id="top"><a href="loginout.php" title="退出">退出</a></div>
     <div id="menu"><ul>
         <li><a href="index.php">管理首页</a></li><li><a href="allcompany.php">案例企业</a></li><li><a href="keymanage.php">关键字</a></li><li><a href="accountmangage.php">帐户管理</a></li>
     </ul></div>
     
     <div id="center">
        <div id="left">
        <div class="title"><strong>行业分类案例</strong></div>
            <div class="grade"><ul>
              <li><a href="allcompany.php?id=1"><img src="img/grade_img1.jpg" />上市公司</a></li>
              <li><a href="allcompany.php?id=2"><img src="img/grade_img2.jpg" />龙头企业</a></li>
              <li><a href="allcompany.php?id=3"><img src="img/grade_img3.jpg" />中小型企业</a></li>
            </ul></div>
        </div>
        
        <div id="right">
          <div class="location"><strong>当前位置 : 管理首页>> 添加企业案例</strong></div>
          <div id="content">
<?php if(@$_GET['action']=="mod"){
           $id=$_GET['id'];
		   $select="select * from custom where id=".$id;
		   $results=mysql_query($select);
		   $rs=mysql_fetch_array($results);
 ?>
         <div class="tablelist">
          <form name="form1" action="casecompany.php?do=domod" method="post" onsubmit="return checknull()">
          <table width="500" border="0" class="table2">
  <tr><td colspan="2"  style="padding-left:180px; font-size:16px; height:30px;">修 改 企 业 信 息</td> </tr>
  <tr><input type="hidden" name="id" value="<?php echo $id;?>" />
    <td width="135" align="right">企业类型:</td>
    <td width="535"><select id="gradeid" name="gradeid"><option value="<?php echo $rs['gradeid'] ?>">请选择企业类别</option>
	     <?php $sql="select * from grade";   $result=mysql_query($sql);
           while($grade=mysql_fetch_array($result)){ echo "<option value='".$grade['gradeid']."'>".$grade['gradename']."</option>"; } ?></select></td>
  </tr>
  <tr>
    <td  align="right">语 言:</td>
    <td><select id="languageid" name="languageid"><option value="<?php echo $rs['languageid'] ?>">请选择语言</option>
	     <?php $sql="select * from language";   $result=mysql_query($sql);
           while($language=mysql_fetch_array($result)){ echo "<option value='".$language['id']."'>".$language['language']."</option>"; } ?></select></td>
  </tr>
  <tr>
    <td  align="right">公司名称:</td>
    <td><input id="company" type="text" name="company" value="<?php echo $rs['company'] ?>" /></td>
  </tr>
  <tr>
    <td align="right">网站地址:</td>
    <td><input id="url" type="text" name="url" value="<?php echo $rs['url'] ?>" /> * (不包含"http://www.")</td>
  </tr>
  <tr>
    <td align="right">计数器编号:</td>
    <td><input id="jsqid" type="text" name="jsqid" value="<?php echo $rs['jsqid'] ?>" /></td>
  </tr>
  <tr>
    <td align="right">案例状态:</td>
    <td><select name="state"><option value="1">正常</option><option value="0">停止</option></select></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="submit" value=" 修 改 " /> &nbsp; <input type="reset" value=" 重 填 " name="reset" /></td>
  </tr>
</table></form></div>
<?php }else{ ?>
          <div class="tablelist">
          <form name="form1" action="casecompany.php?do=doadd" method="post" onsubmit="return checknull()">
          <table width="500" border="0" class="table2">
  <tr><td colspan="2"  style="padding-left:180px; font-size:16px; height:30px;">添 加 企 业 案 例</td> </tr>
  <tr>
    <td width="135" align="right">企业类型:</td>
    <td width="535"><select id="gradeid" name="gradeid"><option value="">请选择企业类别</option>
	     <?php $sql="select * from grade";   $result=mysql_query($sql);
           while($grade=mysql_fetch_array($result)){ echo "<option value='".$grade['gradeid']."'>".$grade['gradename']."</option>"; } ?></select></td>
  </tr>
  <tr>
    <td  align="right">语 言:</td>
    <td><select id="languageid" name="languageid"><option value="">请选择语言</option>
	     <?php $sql="select * from language";   $result=mysql_query($sql);
           while($language=mysql_fetch_array($result)){ echo "<option value='".$language['id']."'>".$language['language']."</option>"; } ?></select></td>
  </tr>
  <tr>
    <td  align="right">公司名称:</td>
    <td><input id="company" type="text" name="company" /></td>
  </tr>
  <tr>
    <td align="right">网站地址:</td>
    <td><input id="url" type="text" name="url" value="" /> * (不包含"http://www.")</td>
  </tr>
  <tr>
    <td align="right">计数器编号:</td>
    <td><input id="jsqid" type="text" name="jsqid" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="submit" value=" 添 加 " /> &nbsp; <input type="reset" value=" 重 填 " name="reset" /></td>
  </tr>
</table></form></div>
<?php } ?>

<script type="text/javascript">
 function  checknull(){
    if(document.getElementById("gradeid").value=='' || document.getElementById("languageid").value=='' || document.getElementById("company").value=='' || document.getElementById("url").value=='' || document.getElementById("jsqid").value==''){
	alert("各项内容都不能为空");
	return false;
	}else{
	return true;
	}
	
 }
</script>              

   
  
          </div>
        </div>
     </div>
     
     <div id="foot"><P>copy right &copy; 2008-2009  <font color="#990000">ETW International</font></P></div>
</div>
</body>
</html>
