大部分使用模板的PHP里都有解决这种问题的现成代码,拷贝来用用就好。

解决方案 »

  1.   

    <?php 
        require_once("../inc/define.inc.php"); 
        require_once("../inc/checklogin.inc.php");  
        require_once("../inc/page.inc.php");  
        require_once "fasttemplate/class.FastTemplate.php3";  
            
        $oper = $_GET["oper"];
        if($oper == "delete")
        { 
           $Users = $_POST["users"];
           DeleteUsers($Users);
           header("location:regmessage.php?status=12");
        }
        $type = $_GET["type"];
        if($type == "confirm")
        {
          $id = $_GET["id"];
          ConfirmMember($id);
          echo "<script language='javascript'>alert(\"批准成功!\");window.location='user_list.php';</script>";
          exit();
        }
        
        //check oper
        $tpl=new FastTemplate("./tpl");
        $tpl->define(array(main => "user_list.tpl"));  
        $tpl->define_dynamic("row2","main");
       
    /************* show page*********************************************************************/      
       set_time_limit(0);
       $pagesize=20;
        
        $Page = $_GET["pagecount"];
        if(!isset($Page))
        {
          $Page = 1;
        }   
        $show_start = ($Page -1 )*$pagesize;
    $p=new show_page;
    $p->pvar="pagecount";
      
      $where = "";
    GetUserInfo(&$Userinfo,&$totle_num, $pagesize, $Page);
    if($totle_num == 0)
      {
        header("location:regmessage.php?status=5");
          exit();
      }
    $p->set($pagesize,$totle_num);
        for($i=0;$i< $pagesize;$i++)
      {
        if($show_start < $totle_num)
        {
          $sub = $Userinfo[$i][Subsibe] == 1 ? "是" : "否";
          $id = $Userinfo[$i][User_id];
          if($Userinfo[$i][User_status] == 1)
          {
             $sub = "<a href='user_list.php?id=$id&type=confirm'>批准</a>";
          }
         $tpl->assign(USER_ID,            $Userinfo[$i][User_id]);  
         $tpl->assign(USER_NAME,          $Userinfo[$i][User_name]); 
         $tpl->assign(USER_TYPE,          $UserType[$Userinfo[$i][User_type]]);
         $tpl->assign(SUBSIBE,            $sub);  
         $tpl->assign(USER_EMAIL,         $Userinfo[$i][User_email]);  
         $tpl->assign(LAST_LOGIN_TIME,    $Userinfo[$i][Last_login_time]); 
         $show_start++;
         $tpl->parse(ROW2,".row2"); 
       }   
        }
        $showpage=$p->output(1);
      $tpl->assign(SHOWPAGE,$showpage);
    $tpl->parse(BODY,"main");
    $tpl->FastPrint("BODY");  
    ?>
    <table class="showframe" width="750">
      <tr>
        <td width="140" class="showhd" align="center">用户名</td>
        <td width="100" class="showhd" align="center">用户类型</td>
        <td width="100" class="showhd" align="center">付费会员</td>
        <td width="120" class="showhd" align="center">用户EMAIL</td>
        <td width="180" class="showhd" align="center">上次登录时间</td>
        <td width="100" class="showhd" align="center">详细信息</td>
      </tr> 
      </table>
      <div id="divAll"> 
      <table class="showdata" width="750">
      <!-- BEGIN DYNAMIC BLOCK: row2 -->
      <tr>
        <td width="5" class="showtd">&nbsp;&nbsp;<input type="checkbox" name="users[]" value="{USER_ID}"></td>
        <td width="135" class="showtd" align="center">{USER_NAME}</td>
        <td width="140" class="showtd" align="center">{USER_TYPE}</td>
        <td width="120" class="showtd" align="center">{SUBSIBE}</td>
        <td width="120" class="showtd" align="center">{USER_EMAIL}</td>
        <td width="180" class="showtd" align="center">{LAST_LOGIN_TIME}</td>
        <td width="100" class="showtd" align="center"><a href="user_add.php?type=edit&User_id={USER_ID}">详细信息</a></td>
      </tr>
     <!-- END DYNAMIC BLOCK: row2 -->
      

  2.   

    连分页都有了!用的是fasttemplate
      

  3.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <link rel="stylesheet" type="text/css" href="../css/main1.css">
    <title>网址列表</title>
    <script language="javascript" src="../js/function.js"></script>
    <script language="javascript" >
       function User_add(myform)
       {
           myform.action = "user_add.php?oper=add";
           myform.submit();
       }
       function User_delete(myform)
       {
           var length = divAll.all.length;
         var checkedcount=0;  
         for(i=0;i<length;i++)
         {  
           if(divAll.all(i).type == "checkbox")
           {
               if(divAll.all(i).checked  == true)
               {
                  checkedcount += 1;
               }
           }           
         }   
         if(checkedcount == 0)
         {
           alert("请选择一个要删除的用户!");
           return;
         }
         if(confirm("确定要删除用户吗?"))
           {
              myform.action = "user_list.php?oper=delete";
              myform.submit(); 
           }
       }
       
    </script>
    </head>
    <body bgcolor="99ccff">
    <form name="myform"  action="" method="post"><table border="0" width="750" >
      <tr>
        <td colspan="2" height="30">
          <font class="showtitle">系统管理&gt;&gt;用户管理</font>
        </td>
      <tr>
    </table>
    <table>
      <tr>
        <td width="10">
        </td>
        <td >
    <table class="showframe" width="750">
      <tr>
        <td width="140" class="showhd" align="center">用户名</td>
        <td width="100" class="showhd" align="center">用户类型</td>
        <td width="100" class="showhd" align="center">付费会员</td>
        <td width="120" class="showhd" align="center">用户EMAIL</td>
        <td width="180" class="showhd" align="center">上次登录时间</td>
        <td width="100" class="showhd" align="center">详细信息</td>
      </tr> 
      </table>
      <div id="divAll"> 
      <table class="showdata" width="750">
      <!-- BEGIN DYNAMIC BLOCK: row2 -->
      <tr>
        <td width="5" class="showtd">&nbsp;&nbsp;<input type="checkbox" name="users[]" value="{USER_ID}"></td>
        <td width="135" class="showtd" align="center">{USER_NAME}</td>
        <td width="140" class="showtd" align="center">{USER_TYPE}</td>
        <td width="120" class="showtd" align="center">{SUBSIBE}</td>
        <td width="120" class="showtd" align="center">{USER_EMAIL}</td>
        <td width="180" class="showtd" align="center">{LAST_LOGIN_TIME}</td>
        <td width="100" class="showtd" align="center"><a href="user_add.php?type=edit&User_id={USER_ID}">详细信息</a></td>
      </tr>
     <!-- END DYNAMIC BLOCK: row2 -->
    </table>
      </div>  
        </td>
      </tr>
    </table>
    <table>
        <tr>
        <td  width="580" align="center">
           <font class="normal">{SHOWPAGE}</font></form>
        </td>
      </tr>
    </table>
    <br>
    <table>
      <tr>
        <td width="580" align="center">
           <!--input type="submit" class="showbuttons"   value="添加用户"  onclick="User_add(myform)"-->
           &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
           <input type="submit" class="showbuttons"   value="删除用户"  onclick="User_delete(myform)">
        </td>
      </tr>
    </table>
    </form>
    </body>
    </html>
    晕,没有发完!
      

  4.   

    用smarty的循环也很简单
    {secion name=i loop=$value}
    <tr>
    <td>{$value[i]['name']}</td><td>{$value[i]['id']}</td><td>{$value[i]['info']}</td>
    </tr>
    {/section}