为什么只有第一页能显示数据,点击下一页就是空的?
下面贴代码
<!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=gb2312"><TITLE>无标题文档</TITLE></head><BODY><table width="765" border="1" align="center"> <tr> <td height="64" align="center" colspan="7"><form id="form1" name="form1" method="post" action=""> <input type="text" name="select"> <input type="submit" name="submit" value="查询"> </form></td> </tr> <?php include("connet.php"); if($_POST['submit']==查询){ $num = 5; $rse = mysql_query("select * from cj"); $nu = mysql_num_rows($rse);//总条目数 if(!$_POST[page]){ $page = 1; }else{ $page = $_POST[page]; } $sql_i=($page - 1)*$num; $rs = mysql_query("SELECT * FROM `cj` LIMIT $sql_i,$num"); $nur = ceil($nu/$num);//总页数 ?> <tr> <td height="29" width="126" align="center" border="1" >学号</td> <td width="74" align="center">姓名</td> <td height="29" width="132" align="center" border="1">课程名称</td> <td height="29" width="82" align="center" border="1">平时成绩</td> <td height="29" width="87" align="center" border="1">期末成绩</td> <td height="29" width="122" align="center" border="1">总评成绩</td> <td height="29" width="96" align="center" border="1">学年</td> </tr> <?php while($rst = mysql_fetch_array($rs)){?> <tr> <td height="43"><?php echo $rst['xh'];?></td> <td><?php echo $rst['xm'];?></td> <td><?php echo $rst['kc'];?></td> <td><?php echo $rst['pscj'];?></td> <td><?php echo $rst['qmcj'];?></td> <td><?php echo $rst['zpcj'];?></td> <td><?php echo $rst['xn'];?></td> </tr><?php }}?> <table width="765" border="1" align="center"> <tr> <td height="64" align="center" colspan="7"><?php echo $nur ?>页共<?php echo $nu ?>条</td><td><? echo "<a href='index.php?id=1&page=1'>首页</a>"; if($page >= 2){?> <a href="index.php?id=1&page=<?php echo $page-1;?>">上一页</a><?php } if($page < $nur){?> <a href="index.php?id=1&page=<?php echo $page+1;?>">下一页</a><?php }?> <a href="index.php?id=1&page=<?php echo $nur;?>">尾页</a></td> </tr> </table> </table></BODY></html>
你传入的参数的GET,但是你接受的参数是POST
翻页 ">下一页
是用 get 方式传值的
表单提交 if($_POST['submit']==查询){
是按 post 方式传值的
这就是问题的原因,想想就明白了
a标签带的是get传值,你用的是$_POST去获得参数.......能接受到就奇怪了
a标签带的是get传值,你用的是$_POST去获得参数.......能接受到就奇怪了