一个数据分页的问题 显示所有数据的分页功能一切正常,但是获取文本框搜索数据的时候分页不正常,只有第一页有数据 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!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=utf-8"><TITLE>无标题文档</TITLE></head><BODY><table width="765" border="1" align="center"> <form action="index.php?id=1" method="get"> <tr> <td height="64" align="center" colspan="7"> <input type="text" id="select" name="select" /><input type="submit" name="submit" value="查询"/></td> </tr> </form> </td> <tr> <td height="29" width="93" align="center" border="1" >学号</td> <td width="55" align="center">姓名</td> <td height="29" width="98" align="center" border="1">课程名称</td> <td height="29" width="61" align="center" border="1">平时成绩</td> <td height="29" width="65" align="center" border="1">期末成绩</td> <td height="29" width="90" align="center" border="1">总评成绩</td> <td height="29" width="51" align="center" border="1">学年</td> </tr> <?php include("connet.php"); if($_GET['select']==""){ $num = 4; $rse = mysql_query("select * from cj"); $nu = mysql_num_rows($rse);//总条目数 if(!$_GET[page]){ $page = 1; }else{ $page = $_GET[page]; } $sql_i=($page - 1)*$num; $nur = ceil($nu/$num);//总页数 $rs = mysql_query("SELECT * FROM `cj` LIMIT $sql_i,$num"); 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 }?> <tr> <td height="64" align="center" colspan="8"> <?php echo $page ?>/<?php echo $nur ?>页共<?php echo $nu ?>条<? 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> <?php }?> <?php if($_GET['submit']=="查询"){ $select=$_GET['select']; $num = 4; @$rse = mysql_query("SELECT * FROM `cj` WHERE `xm`= '$select'"); $nu = mysql_num_rows($rse);//总条目数 if(!$_GET[page]){ $page1 = 1; }else{ $page1 = $_GET[page]; } $sql_i=($page1 - 1)*$num; $nur = ceil($nu/$num);//总页数 $rs = mysql_query("SELECT * FROM `cj` WHERE `xm`= '$select' LIMIT $sql_i,$num"); 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 }?> <tr> <td height="64" align="center" colspan="8"> <?php echo $page1 ?>/<?php echo $nur ?>页共<?php echo $nu ?>条<? echo "<a href='index.php?id=1&page1=1'>首页</a>"; if($page1 >= 2){?> <a href="index.php?id=1&page1=<?php echo $page1-1;?>">上一页</a> <?php } if($page1 < $nur){?> <a href="index.php?id=1&page1=<?php echo $page1+1;?>">下一页</a> <?php }?> <a href="index.php?id=1&page1=<?php echo $nur;?>">尾页</a></td></tr> <?php }?> </table> </BODY></html> 翻页 url 中没有 select,自然第二页起就不按规则来了 $select=$_GET['select'];这个变量,你都没定义,怎么可能有值? Array( [c] => pay2 [cart] => 1 [itemid] => Array ( [0] => 103 [1] => 104 [2] => 105 [3] => 106 ) [PHPSESSID] => rdkrfasknosmg58o1r1d9i6pf5) Array( [c] => pay2 [cart] => 1 [itemid] => Array ( [0] => 103 [1] => 104 [2] => 105 [3] => 106 ) [PHPSESSID] => rdkrfasknosmg58o1r1d9i6pf5)测试下插件 为什么我的memcached win 安装不成功 mysql 查询 ★WebNoteEditor在线编辑器终于推出PHP版本了. 我这样的在北京能拿多少米 php编程的前景如何 关于drop table,有没有类似like匹配的用法? 问个用ftp上传文件的问题?? 原来mysql的fulltext搜索不支持中文!!!!!!!!!!!!!!! 以下代码不能去掉内容里面最后的回车换行符,怎么回事? 基于php的宿舍管理系统 MySQL重置密码失败 抛出变量为啥没有输出呢
<!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=utf-8">
<TITLE>无标题文档</TITLE>
</head>
<BODY><table width="765" border="1" align="center">
<form action="index.php?id=1" method="get">
<tr>
<td height="64" align="center" colspan="7">
<input type="text" id="select" name="select" />
<input type="submit" name="submit" value="查询"/></td>
</tr>
</form>
</td>
<tr>
<td height="29" width="93" align="center" border="1" >学号</td>
<td width="55" align="center">姓名</td>
<td height="29" width="98" align="center" border="1">课程名称</td>
<td height="29" width="61" align="center" border="1">平时成绩</td>
<td height="29" width="65" align="center" border="1">期末成绩</td>
<td height="29" width="90" align="center" border="1">总评成绩</td>
<td height="29" width="51" align="center" border="1">学年</td>
</tr>
<?php
include("connet.php");
if($_GET['select']==""){
$num = 4;
$rse = mysql_query("select * from cj");
$nu = mysql_num_rows($rse);//总条目数
if(!$_GET[page]){
$page = 1;
}else{
$page = $_GET[page];
}
$sql_i=($page - 1)*$num;
$nur = ceil($nu/$num);//总页数
$rs = mysql_query("SELECT * FROM `cj` LIMIT $sql_i,$num");
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 }?>
<tr>
<td height="64" align="center" colspan="8">
<?php echo $page ?>/<?php echo $nur ?>页
共<?php echo $nu ?>条<? 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>
<?php }?>
<?php if($_GET['submit']=="查询"){ $select=$_GET['select'];
$num = 4;
@$rse = mysql_query("SELECT * FROM `cj` WHERE `xm`= '$select'");
$nu = mysql_num_rows($rse);//总条目数
if(!$_GET[page]){
$page1 = 1;
}else{
$page1 = $_GET[page];
}
$sql_i=($page1 - 1)*$num;
$nur = ceil($nu/$num);//总页数
$rs = mysql_query("SELECT * FROM `cj` WHERE `xm`= '$select' LIMIT $sql_i,$num");
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 }?>
<tr>
<td height="64" align="center" colspan="8">
<?php echo $page1 ?>/<?php echo $nur ?>页
共<?php echo $nu ?>条<? echo "<a href='index.php?id=1&page1=1'>首页</a>";
if($page1 >= 2){
?>
<a href="index.php?id=1&page1=<?php echo $page1-1;?>">上一页</a>
<?php
}
if($page1 < $nur){
?>
<a href="index.php?id=1&page1=<?php echo $page1+1;?>">下一页</a>
<?php
}
?>
<a href="index.php?id=1&page1=<?php echo $nur;?>">尾页</a></td>
</tr>
<?php }?>
</table>
</BODY></html>
(
[c] => pay2
[cart] => 1
[itemid] => Array
(
[0] => 103
[1] => 104
[2] => 105
[3] => 106
) [PHPSESSID] => rdkrfasknosmg58o1r1d9i6pf5
)
Array
(
[c] => pay2
[cart] => 1
[itemid] => Array
(
[0] => 103
[1] => 104
[2] => 105
[3] => 106
) [PHPSESSID] => rdkrfasknosmg58o1r1d9i6pf5
)
测试下插件