<?php include 'yanzheng.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" type="text/css" href="css/css.css" />

<script language="javascript" type="text/javascript">
function preg_match(regStr, str)
{
     var objRegExp = new RegExp(regStr);
     return objRegExp.test(str);
}
function SelectAll(form)
{
for(var j = 0;j < form.elements.length;j++)
     {
         var e = form.elements[j];
         if(preg_match(/del_id/, e.name))
         {
             e.checked = form.select_all.checked;
         }
         else
         {
             continue;
         }
     }
}
</script>
</head>

<body>
<?php require_once 'head.php';?>
<div class="box">


    <form action="user_up.php" method="get">
	<input name="user" type="text" />
    <input name="submit" type="submit" value="搜索" />	
	</form>


	<form name="del_form" action="" method="post"> 
	
	<table width="100%" height="40" border="0" cellpadding="0" cellspacing="0"   class="borer">
	  <tr style="background-color:#EEEEEE;">
	    <td width="80" height="31" >选择</td>
		<td width="80" height="31" >ID</td>
		<td width="200" >用户名</td>
		<td width="200">密码</td>
		<td width="200" >注册时间</td>
		
	  </tr>

	<!--list start-->	



<?php 	

	require_once('page.class.php'); //分页类
			$showrow = 10; //一页显示的行数
			$curpage = empty($_GET['page']) ? 1 : $_GET['page']; //当前的页,还应该处理非数字的情况
			$url = "?page={page}"; //分页地址，如果有检索条件 ="?page={page}&q=".$_GET['q']
			//省略了链接mysql的代码，测试时自行添加
			$sql = "SELECT * FROM user $m";
			$total = mysql_num_rows(mysql_query($sql)); //记录总条数
			if (!empty($_GET['page']) && $total != 0 && $curpage > ceil($total / $showrow))
				$curpage = ceil($total_rows / $showrow); //当前页数大于最后页数，取最后一页
			//获取数据
			$sql .= " order by id desc LIMIT " . ($curpage - 1) * $showrow . ",$showrow;";
		//	$query = mysql_query($sql);
			$arr=listquery($sql);
			foreach ($arr as $v){?>
	  <tr>
		<td><input name="del_id[]" type="checkbox" id="del_id[]" value="<?=$v['id']?>" /></td>
		<td><?=$v['id']?></td>
		<td><?=$v['user']?></td>
		<td><input name="pwd<?=$v['id']?>"  type="text" style=" text-align:center;" value="<?=$v[pwd]?>" /></td>
	    <td><?=$v['time']?></td>		
	
	  </tr>
   
	<?php }?>
 </table>    
  
	<table width="50%" height="28" border="0" cellpadding="0" cellspacing="0" style="margin-top:20px;">
	  <tr>	
	    <td width="49">全选</td>
		<td width="49"><input id="select_all" name="select_all" type="checkbox" value="1" onClick="SelectAll(this.form)"/></td>
	    <td width="80" ><input name="submitdel" type="submit" value="批量删除" class="reganniu" /></td>
		 <td width="200">

		 <input name="submitxg" type="submit" value="批量修改" class="reganniu" />
		 
		 </td>
	  </tr>
	</table>
	 <?php
	    $houzhui='&benpath='.$_GET[benpath].'';
   
		$page = new page($total, $showrow, $curpage, $url, 2,$houzhui);
		echo $page->myde_write();

	?>


	 </form>



<?php
if($_POST['submitxg']){
$del_id=$_POST['del_id']; //数组


     if($del_id!=""){ 
             $del_num=count($del_id); 
             for($i=0;$i<$del_num;$i++){ 
			
				 $pwd=$_POST['pwd'.$del_id[$i]];		 
                 mysql_query("update user set pwd='$pwd' where id='$del_id[$i]'"); 
				
             }  
            msg('修改成功','url_type.php');
      }else{ 
           msg('请选择','url_type.php');
      }

  }
?>  

<!--批量修改-->




  <?php
if($_POST['submitdel']){

$del_id=$_POST['del_id'];
     if($del_id!=""){ 
             $del_num=count($del_id); 
             for($i=0;$i<$del_num;$i++){ 
                 mysql_query("Delete from user where id='$del_id[$i]'"); 				
             }  
             msg('删除成功',$onurl);
      }else{ 
             msg('请选择',$onurl);
      }

  }
?>  


</div>

<?php require_once 'foot.php';?>
</body>
</html>