<?php
require_once("../global/checkuser2.php");
?>
<!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>修改网站</title>
<link rel="stylesheet" href="addmodify.css" />
<script>
function check(){
var webname=document.getElementById("name").value;
var url=document.getElementById("url").value;
var type=document.getElementById("type").value;
var user=document.getElementById("user").value;
if(webname==""){
alert("网站名称不能为空");
return false;
}
if(url==""){
alert("网站地址不能为空");
return false;
}
if(type==""){
alert("外链类型不能为空");
return false;
}
if(user==""){
alert("发布人不能为空");
return false;
}
}
function initselect(){
var ve = document.getElementById("typee").value;
var st = document.getElementById("type");
for(var i=0;i<st.options.length;i++){
  if(ve==st.options[i].value){
       st.selectedIndex = i;
       break;
  }
}

}
function initselect2(){
var vee = document.getElementById("userr").value;
var ste = document.getElementById("user");
for(var i=0;i<ste.options.length;i++){
  if(vee==ste.options[i].value){
       ste.selectedIndex = i;
       break;
  }
}

}
</script>
</head>

<body>
<div class="bigdiv">
<div class="toptitle">&nbsp;&nbsp;&nbsp;修改网站链接<a href="index.php" style="float:right;margin-right:30px;display:inline;">返回</a></div>
<div class="list">
<?php
require_once("../global/connect.php");
$rows=mysql_fetch_array(mysql_query("select * from weblink where id=$_GET[id]"));
?>
<input type="hidden" id="typee" value="<?=$rows['linktype']?>" />
<input type="hidden" id="userr" value="<?=$rows['user']?>" />
<form action="function.php?mod=modify" method="post" onsubmit="return check()">
<div class="content">
<ul>
<li>&nbsp;&nbsp;&nbsp;链接ID：<input type="text" id="id" name="id" value="<?=$rows['id']?>" readonly="readonly"/></li>
<li>网站名称：<input type="text" id="name" name="name" value="<?=$rows['name']?>" /></li>
<li>网站地址：<input type="text" id="url" name="url" value="<?=$rows['url']?>" style="width:290px;"readonly="readonly" /></li>
<li>外链类型：<select id="type" name="type">
<option value="">外链类型</option>
<?php
			  $rss=mysql_query("select * from linktype");
			   if($rss){
			   while($row=mysql_fetch_array($rss)){?>
			   <option value="<?=$row['name']?>"><?=$row['name']?></option>
			 <?php }}?>
</select><script>initselect();</script></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PR值：<input type="text" id="pr" name="pr" value="<?=$rows['pr']?>" readonly="readonly"/></li>
<li>百度收录：<input type="text" id="baidu" name="baidu" value="<?=$rows['baidu']?>" readonly="readonly"/></li>
<li>链接状态：<input type="text" id="linkstate" name="linkstate" value="<?=$rows['linkstate']?>" readonly="readonly"/></li>
<li>&nbsp;&nbsp;&nbsp;&nbsp;发布人：<select id="user" name="user">
<option value="">发布人</option>
<?php
			  $rs=mysql_query("select * from user");
			   if($rs){
			   while($row=mysql_fetch_array($rs)){?>
			   <option value="<?=$row['name']?>"><?=$row['name']?></option>
			 <?php }}?>
</select><script>initselect2();</script></li>
<li style="text-align:center;height:40px;line-height:40px;"><input type="submit" value="提交" class="btn"/></li>
</ul>
</div>
</form>
</div>
</div>
</body>
</html>
