我想把下面做成分页功能,请帮忙看下要怎么修改!谢谢<?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;"> </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; ?> 张 状态:<?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"> 共有编程词典 <?php echo $total1;?> 个 每页显示 <?php echo $pagesize1;?> 个 第 <?php echo $page1;?> 页/共 <?php echo $pagecount1;?> 页</div></td>
<td width="317"><div align="right"><a href="<?php echo $_SERVER["PHP_SELF"]?>?page=1" class="a1">首页</a> <a href="<?php echo $_SERVER["PHP_SELF"]?>?page=<?php
if($page1>1)
echo $page1-1;
else
echo 1;
?>" class="a1">上一页</a> <a href="<?php echo $_SERVER["PHP_SELF"]?>?page=<?php
if($page1<$pagecount1)
echo $page1+1;
else
echo $pagecount1;
?>" class="a1">下一页</a> <a href="<?php echo $_SERVER["PHP_SELF"]?>?page=<?php echo $pagecount1;?>" class="a1">尾页</a> </div> </td>
</tr>
</table>
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;"> </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; ?> 张 状态:<?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"> 共有编程词典 <?php echo $total1;?> 个 每页显示 <?php echo $pagesize1;?> 个 第 <?php echo $page1;?> 页/共 <?php echo $pagecount1;?> 页</div></td>
<td width="317"><div align="right"><a href="<?php echo $_SERVER["PHP_SELF"]?>?page=1" class="a1">首页</a> <a href="<?php echo $_SERVER["PHP_SELF"]?>?page=<?php
if($page1>1)
echo $page1-1;
else
echo 1;
?>" class="a1">上一页</a> <a href="<?php echo $_SERVER["PHP_SELF"]?>?page=<?php
if($page1<$pagecount1)
echo $page1+1;
else
echo $pagecount1;
?>" class="a1">下一页</a> <a href="<?php echo $_SERVER["PHP_SELF"]?>?page=<?php echo $pagecount1;?>" class="a1">尾页</a> </div> </td>
</tr>
</table>
也许这个能帮到你。看着改。我也是这样的。
?>
<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>
<? } ?><!--主题翻页-->也许代码很乱,但是原理很简单的,希望给你有帮助.