我想把下面做成分页功能,请帮忙看下要怎么修改!谢谢<?php
include_once 'conn/connpic.php';
include_once 'admin/inc/func.php';
?>
<table border="0" cellpadding="10" cellspacing="0" align="center">
  <tr>
    <td colspan="5" style="background-image:url(images/centertop.gif); background-position: top; background-repeat:no-repeat; width: 774px; height: 42px;">&nbsp;</td>
<?php
$typesql = "select id,typename,membername,level,indexpic from tb_typepic where level = 0 order by id desc limit 16";
$typearr = $conne->getRowsArray($typesql);
$conne->close_rst();
foreach($typearr as $key => $typevalue){
$numsql = "select id from tb_photo where typename = ".$typevalue['id'];
$num = $conne->getRowsNum($numsql);
if($key % 4 == 0){
?>
  </tr>
  <tr>
<?php
}else{
?>
<?php

}
?>
    <td>
      <table border="0" cellpadding="0" cellspacing="0" align="center">
    <tr>
          <td width="181" height="115" align="center" valign="middle" >
<?php
if($num != 0){
?>
<a href="pics.php?smallact=<?php echo $typevalue['id']; ?>" target="showpic">
<?php
}
?>
<img id = "indexpic<?php echo $key; ?>" src="<?php echo ($num != 0?'uppics/'.$typevalue['indexpic']:'images/null.jpg'); ?> " width="<?php echo getWidth(($num != 0?'uppics/'.$typevalue['indexpic']:'images/null.jpg'),150,113); ?>" height="<?php echo getHeight(($num != 0?'uppics/'.$typevalue['indexpic']:'images/null.jpg'),150,113); ?>" border="0"/>
<?php
if($num != 0){
?>
</a>
<?php
}
?>
          </td>
    </tr>
    <tr>
  <td height="25" align="center" valign="middle">名称:<?php echo $typevalue['typename']; ?><br /><?php echo $num; ?>&nbsp;张&nbsp;状态:<?php echo ($typevalue['level'] == 0?'<font color=green>公开</font>':'<font color=red>私藏</font>'); ?><br />
拥有者:<a href="<?php echo $typevalue['membername'];  ?>/" target="_blank"><?php echo $typevalue['membername'] ?></a>
  </td>
    </tr>
      </table>
    </td>
<?php
}
?>
  </tr>
</table><table width="774" height="25" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
  <tr>
    <td width="531"><div align="left">&nbsp;&nbsp;共有编程词典&nbsp;<?php echo $total1;?>&nbsp;个&nbsp;每页显示&nbsp;<?php echo $pagesize1;?>&nbsp;个&nbsp;第&nbsp;<?php echo $page1;?>&nbsp;页/共&nbsp;<?php echo $pagecount1;?>&nbsp;页</div></td>
              <td width="317"><div align="right"><a href="<?php echo $_SERVER["PHP_SELF"]?>?page=1" class="a1">首页</a>&nbsp;<a href="<?php echo $_SERVER["PHP_SELF"]?>?page=<?php 
 if($page1>1) 
  
   echo $page1-1;
  else
   echo 1;  
   ?>" class="a1">上一页</a>&nbsp;<a href="<?php echo $_SERVER["PHP_SELF"]?>?page=<?php 
 if($page1<$pagecount1) 
  
   echo $page1+1;
  else
   echo $pagecount1;  
   ?>" class="a1">下一页</a>&nbsp;<a href="<?php echo $_SERVER["PHP_SELF"]?>?page=<?php echo $pagecount1;?>" class="a1">尾页</a>&nbsp;&nbsp;</div>    </td>
  </tr>
</table>

解决方案 »

  1.   

    http://linux.chinaitlab.com/PHP/722000.html自己的代码自己懂,我看得很晕
    也许这个能帮到你。看着改。我也是这样的。
      

  2.   

    贴点分页的代码给你吧,是我自己做的,实验已经成功了function ZTLB($Id_MK,$Type_ZT,$PaiXu_ZT,$Page_ZT){//主题列表, Id_MK:模块的Id , Type_ZT主题的类型 , PaiXu_ZT主题的排序 , Page_ZT要到达的页数.
    ?>
    <TABLE class=bordercolor style="MARGIN-TOP: 1px" cellSpacing=1 cellPadding=3 width="100%" border=0>
    <TBODY>
    <tr class=Tdbg_BaiSe><!--板块属性-->
    <td class=Tdbg_BaiSe>
    <!--Table 板块属性  -->
    <table  width="100%">
    <tr>
    <td width="50">
    <img src="<?php Pic_MK($Id_MK) ?>" width="50" height="50">
    </td>
    <TD vAlign=top width="100%" colSpan=2>
    <!--Table 板块属性_版主等信息  -->
    <table width="100%" cellspacing="0">
    <tr>
    <td width="400">
    <span style="FONT-SIZE: 120%;" class="STYLE1">
    <?php Name_MK($Id_MK) ?>
    </span>
    <? SUM_JRZT($Id_MK); ?> /
    <? SUM_ZT($Id_MK); ?> 
    </td>
    </tr>
    <tr>
    <td>
    <?php Text_MK($Id_MK) ?>
    </td>
    </tr>
    <tr>
    <td>
    版主:<?php User_MK($Id_MK) ?> 
    </td>
    </tr>
    </table>
    <!--Table 板块属性_版主等信息  -->
    </TD>
    </tr>
    </table>
    <!--Table 板块属性  -->
    </td>
    </tr><!--板块属性-->
    <tr class=Tdbg_BaiSe><!--翻页-->
    <td class=Tdbg_BaiSe>
    <? tPage_ZT($Page_ZT,$Id_MK,2,$Type_ZT,$PaiXu_ZT)?>
    </td>
    </tr><!--翻页-->
    <?
    if($Type_ZT=='全部' & $Page_ZT==1){//特 殊 主 题
    ?>
    <tr bgcolor="#ffffff">
    <td height="30">
    <b>特 殊 主 题</b>
    </td>
    </tr>
    <?
    $sql=mysql_query("select * from name_ZTLB where tDady ='$Id_MK' and tType='特殊'");
    while($rs_ZT=mysql_fetch_object($sql)){
    ?>
    <tr bgcolor="#ffffff" onmouseover="this.bgColor='#C7FFFF'" onmouseout="this.bgColor='#ffffff'">
    <td>
    <!--Table 一个主题的基本属性  -->
    <table width="100%">
    <tr>
    <td  width="30" height="30">
    <img src="images\Pic1\FengGe1\ZTTB\hot.gif"><? //print $i ?>
    </td>
    <td>
    <b><a href=javascript:Id_ZT=<? print $rs_ZT->tId ?>;tDo('TZLB')><? print $rs_ZT->tTitle; ?></a></b>
    </td>
    <td  width="100">
    <?php User_Name($rs_ZT->tUserId) ?>
    <p style="margin-top: 0; margin-bottom: 0">2011-06-02</p>
    </td>
    <td  width="100">
    1/2
    </td>
    <td  width="100">
    <p style="margin-top: 0; margin-bottom: 0"><?php User_Name($rs_ZT->tUserId) ?></p>
    <p style="margin-top: 0; margin-bottom: 0">2011-06-02</p>
    </td>
    </tr>
    </table>
    <!--Table 一个主题的基本属性  -->
    </td>
    </tr>
    <? }
    }//特 殊 主 题
    if($Page_ZT==1){
    ?>
    <tr bgcolor="#ffffff">
    <td height="30">
    <b> 正 文 主 题</b>
    </td>
    </tr> <? }
    if($Type_ZT=='全部'){
    $sql=mysql_query("select * from name_ZTLB where tDady ='$Id_MK' and tType=''  Order by tId limit ".($Page_ZT-1)*2 .",2");
    }
    while($rs_ZT=mysql_fetch_object($sql)){
    ?>
    <tr bgcolor="#ffffff" onmouseover="this.bgColor='#C7FFFF'" onmouseout="this.bgColor='#ffffff'">
    <td>
    <!--Table 一个主题的基本属性  -->
    <table width="100%">
    <tr>
    <td  width="30" height="30">
    <img src="images\Pic1\FengGe1\ZTTB\hot.gif"><? //print $i ?>
    </td>
    <td>
    <b><a href="javascript:Id_ZT=<? print $rs_ZT->tId ?>;tDo('TZLB')"><? print $rs_ZT->tTitle; ?></a></b>
    </td>
    <td  width="100">
    <?php User_Name($rs_ZT->tUserId) ?>
    <p style="margin-top: 0; margin-bottom: 0">2011-06-02</p>
    </td>
    <td  width="100">
    1/2
    </td>
    <td  width="100">
    <p style="margin-top: 0; margin-bottom: 0"><?php User_Name($rs_ZT->tUserId) ?></p>
    <p style="margin-top: 0; margin-bottom: 0">2011-06-02</p>
    </td>
    </tr>
    </table>
    <!--Table 一个主题的基本属性  -->
    </td>
    </tr>
    <? } ?>
    <tr class=Tdbg_BaiSe><!--翻页-->
    <td class=Tdbg_BaiSe>
    <? tPage_ZT($Page_ZT,$Id_MK,2,$Type_ZT,$PaiXu_ZT)?>
    </td>
    </tr><!--翻页-->
     </TBODY>
    </TABLE>
    <!--TableA结束  -->
    <? }//主题列表
    <? function tPage_ZT($Page,$Id,$Num,$Type,$PaiXu) 
       {//Page当前页数,Id当前模块id,Num一页显示的记录数,Type帖子类型?><!--主题翻页-->
    <table  align="right" border=0>
    <tr>
    <td>
    <?  if($Page>1){ //当页数大于1时,可以有上翻一页 ?>
    <A href="javascript:Id_MK=<? print $Id ?>;Type_ZT='<? print $Type ?>';Page_ZT=<? print $Page-1 ?>;PaiXu_ZT='<? print $PaiXu ?>';tDo('ZTLB');">[上一页]</A>
    <?  }else{  //当页数不大于1时,不能上翻一页 ?>
    [上一页]
    <? }
    switch ($Type){ 
    case "全部" :
    $j2=ceil(mysql_num_rows(mysql_query("select * from name_ZTLB where tDady ='$Id' and tType=''"))/$Num);// tType=''是没有进行类型过滤的打开同一模块下的所有主题
    }
    if ($j2>1){//超过一页时
    for($i=0;$j2>$i;$i++){
    if($i+1!=$Page){//不是当前页可以被点击,可以实现翻页.?>
    <!--<a href="index.php?action1=ZTLB&MKId=<? //print $Id ?>&ZT_Type=<? //print $Type ?>&ZT_Page=<? //print $i+1 ?>">-->
    <A href="javascript:Id_MK=<? print $Id ?>;Type_ZT='<? print $Type ?>';Page_ZT=<? print $i+1 ?>;PaiXu_ZT='<? print $PaiXu ?>';tDo('ZTLB');">
    [<? print $i+1; ?>]
    </a>
    <? }else{?>
    <? print $i+1; ?>
    <? }
    }
    }else{//只有一页时
    print 1;
    }
    if ($j2>$Page){//还没有翻到最后一页时,可以向下翻页
    ?>
    <A href="javascript:Id_MK=<? print $Id ?>;Type_ZT='<? print $Type ?>';Page_ZT=<? print $Page+1 ?>;PaiXu_ZT='<? print $PaiXu ?>';tDo('ZTLB');">[下一页]</A>
    <? }else{ //翻到最后一页时,不可以向下翻页 ?>
    [下一页]
    <? } ?>
    </td>
    </tr>
    </table>
    <? } ?><!--主题翻页-->也许代码很乱,但是原理很简单的,希望给你有帮助.