求大神帮我做个php页面的换页!第一页第二页那种!
1个回答
展开全部
<?php
require_once("conn.php");
$ind_cont_sel_sql="select * from `board` order by `sn` desc";
$ind_cont_sel_query = mysql_query($ind_cont_sel_sql);
$page_info_num = 3;
$page_def = 1;
if (isset($_GET['pagenum'])){
$page_def = $_GET['pagenum'];
}
$sql_page_num = ($page_def - 1)*$page_info_num;
$sql_query_limit=$ind_cont_sel_sql." LIMIT ".$sql_page_num.",".$page_info_num;
$sql_query_limit_info=mysql_query($sql_query_limit);
$all_info_num = mysql_num_rows($ind_cont_sel_query);
$all_page_num = ceil($all_info_num/$page_info_num);
?>
<table width="100%" border="0">
<?php
$i=0;
while($ind_cont_sel_row=mysql_fetch_assoc($sql_query_limit_info)){ $i++; ?>
<tr>
<td colspan="2"><div class="post-utility"><p><h1><u><?php echo $sql_page_num+$i;?></u></h1></p></div></td>
</tr>
<tr>
<td width="80px"><p>title</p></td><td><?php echo nl2br($ind_cont_sel_row["title"]);?></td>
</tr>
<tr>
<td width="80px"><p>name</p></td><td><?php echo nl2br($ind_cont_sel_row["name"]);?></td>
</tr>
<tr>
<td width="80px"><p>time</p></td><td><?php echo nl2br($ind_cont_sel_row["time"]);?></td>
</tr>
<tr>
<td width="80px"><p>content</p></td><td><?php echo nl2br($ind_cont_sel_row["content"]);?></td>
</tr>
<tr><td colspan="2"><hr></td></tr>
<?php } ?>
<tr><td colspan="2" height="10px" align="center">
<a href="?pagenum=1">page</a>
<?
if ($_GET["pagenum"]!=1){ ?>
<a href="?pagenum=<? echo $_GET["pagenum"]-1; ?>">up</a>
<?
}else{
echo "";
} ?>
<?
for($page_num=($_GET["pagenum"]-2);$page_num<$_GET["pagenum"];$page_num++){
if ($page_num<=0){
echo "";
}else{?>
<a href="?pagenum=<?php echo $page_num;?>"><?php echo $page_num;?></a>
<?
}}
?>
<?php echo $_GET["pagenum"];?>
<!--<a href="?pagenum=<?php echo $_GET["pagenum"];?>"><?php echo $_GET["pagenum"];?></a>-->
<?
for($page_num=$_GET["pagenum"]+1;$page_num<=($_GET["pagenum"]+2);$page_num++){
if ($page_num>$all_page_num){
echo "";
}else{
?>
<a href="?pagenum=<?php echo $page_num;?>"><?php echo $page_num;?></a>
<?
}
}
?>
<?
if ($_GET["pagenum"]<$all_page_num){ ?>
<a href="?pagenum=<? echo $_GET["pagenum"]+1; ?>">next</a>
<?
}else{
echo "";
} ?>
<a href="?pagenum=<?php echo $all_page_num;?>">last</a>
</td>
</tr>
</table>
require_once("conn.php");
$ind_cont_sel_sql="select * from `board` order by `sn` desc";
$ind_cont_sel_query = mysql_query($ind_cont_sel_sql);
$page_info_num = 3;
$page_def = 1;
if (isset($_GET['pagenum'])){
$page_def = $_GET['pagenum'];
}
$sql_page_num = ($page_def - 1)*$page_info_num;
$sql_query_limit=$ind_cont_sel_sql." LIMIT ".$sql_page_num.",".$page_info_num;
$sql_query_limit_info=mysql_query($sql_query_limit);
$all_info_num = mysql_num_rows($ind_cont_sel_query);
$all_page_num = ceil($all_info_num/$page_info_num);
?>
<table width="100%" border="0">
<?php
$i=0;
while($ind_cont_sel_row=mysql_fetch_assoc($sql_query_limit_info)){ $i++; ?>
<tr>
<td colspan="2"><div class="post-utility"><p><h1><u><?php echo $sql_page_num+$i;?></u></h1></p></div></td>
</tr>
<tr>
<td width="80px"><p>title</p></td><td><?php echo nl2br($ind_cont_sel_row["title"]);?></td>
</tr>
<tr>
<td width="80px"><p>name</p></td><td><?php echo nl2br($ind_cont_sel_row["name"]);?></td>
</tr>
<tr>
<td width="80px"><p>time</p></td><td><?php echo nl2br($ind_cont_sel_row["time"]);?></td>
</tr>
<tr>
<td width="80px"><p>content</p></td><td><?php echo nl2br($ind_cont_sel_row["content"]);?></td>
</tr>
<tr><td colspan="2"><hr></td></tr>
<?php } ?>
<tr><td colspan="2" height="10px" align="center">
<a href="?pagenum=1">page</a>
<?
if ($_GET["pagenum"]!=1){ ?>
<a href="?pagenum=<? echo $_GET["pagenum"]-1; ?>">up</a>
<?
}else{
echo "";
} ?>
<?
for($page_num=($_GET["pagenum"]-2);$page_num<$_GET["pagenum"];$page_num++){
if ($page_num<=0){
echo "";
}else{?>
<a href="?pagenum=<?php echo $page_num;?>"><?php echo $page_num;?></a>
<?
}}
?>
<?php echo $_GET["pagenum"];?>
<!--<a href="?pagenum=<?php echo $_GET["pagenum"];?>"><?php echo $_GET["pagenum"];?></a>-->
<?
for($page_num=$_GET["pagenum"]+1;$page_num<=($_GET["pagenum"]+2);$page_num++){
if ($page_num>$all_page_num){
echo "";
}else{
?>
<a href="?pagenum=<?php echo $page_num;?>"><?php echo $page_num;?></a>
<?
}
}
?>
<?
if ($_GET["pagenum"]<$all_page_num){ ?>
<a href="?pagenum=<? echo $_GET["pagenum"]+1; ?>">next</a>
<?
}else{
echo "";
} ?>
<a href="?pagenum=<?php echo $all_page_num;?>">last</a>
</td>
</tr>
</table>
更多追问追答
追问
这个怎么用? 我没接触过PHP。8 5 7 9 4 1 2 3 8我的QQ+++
追答
只是个范例罢了
贴进你的程式码后看一下它是怎么运作的自然你就会了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |