我的分页定值是是显示正常的,翻页显示正常,但一旦赋值(我希望别人输入日期,可以自动去找那个月的资料),就不行了,第一页是正常的,第二页就开始无法正常显示了,我觉得大概是值没有传到下一页,但我不会改啊~求大家帮忙
经理开始没耐心了~我快疯了,输入日期页面,scym.php<html>
<title>日期</title>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body><form method="post" action="szym.php">
数据日期格式(如:201206)
<br />
<p>
请输入日期:
<input type="text" name="rq" size="10">
<input type="submit" name="submit" value="确定">
</p>
</form>
<body>
<html>显示页面,szym.php<html>
<head>
<title>数据</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8"></head>
<body><?php
include("conn.php")
?>
<?php$rql = $_POST[rq];
$Page_size=15;$results = mysql_query("select date(visit_time) as dv,answer_type as atl,count(1) as co from om_log_ask_detail_$rql group by date(visit_time),answer_type");
$count = mysql_num_rows($results);
$page_count = ceil($count/$Page_size);$init=1;
$page_len=5;
$max_p=$page_count;
$pages=$page_count;
if(empty($_GET['page'])||$_GET['page']<0){
$page=1;
}else {
$page=$_GET['page'];
}$offset=$Page_size*($page-1);
$sql = "select date(visit_time) as dv,answer_type as atl,count(1) as co from om_log_ask_detail_$rql group by date(visit_time),answer_type limit $offset,$Page_size";$result=mysql_query($sql);echo "<h1>" ."数据资料($rql)". "</h1>";echo "<table frame='box' border='1'>
<tr>
<th>日期</th>
<th>回答类型</th>
<th>数量</th>
</tr>";while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['dv'] . "</td>";
echo "<td>" . $row['atl'] . "</td>";
echo "<td>". $row['co'] . "</td>";
echo "</tr>";
}echo "</table>";mysql_close($con);?><?php$page_len = ($page_len%2)?$page_len:$pagelen+1;//页码个数
$pageoffset = ($page_len-1)/2;//页码个数左右偏移量$key='<div class="page">';
$key.="<span>$page/$pages</span> "; //第几页,共几页
if($page!=1){
$key.="<a href=\"".$_SERVER['PHP_SELF']."?rq=$rql&page=1\">第一页</a> "; //第一页
$key.="<a href=\"".$_SERVER['PHP_SELF']."?rq=$rql&page=".($page-1)."\">上一页</a>"; //上一页
}else {
$key.="第一页 ";//第一页
$key.="上一页"; //上一页
}
if($pages>$page_len){
//如果当前页小于等于左偏移
if($page<=$pageoffset){
$init=1;
$max_p = $page_len;
}else{//如果当前页大于左偏移
//如果当前页码右偏移超出最大分页数
if($page+$pageoffset>=$pages+1){
$init = $pages-$page_len+1;
}else{
//左右偏移都存在时的计算
$init = $page-$pageoffset;
$max_p = $page+$pageoffset;
}
}
}
for($i=$init;$i<=$max_p;$i++){
if($i==$page){
$key.=' <span>'.$i.'</span>';
} else {
$key.=" <a href=\"".$_SERVER['PHP_SELF']."?rq=$rql&page=".$i."\">".$i."</a>";
}
}
if($page!=$pages){
$key.=" <a href=\"".$_SERVER['PHP_SELF']."?rq=$rql&page=".($page+1)."\">下一页</a> ";//下一页
$key.="<a href=\"".$_SERVER['PHP_SELF']."?rq=$rql&page={$pages}\">最后一页</a>"; //最后一页
}else {
$key.="下一页 ";//下一页
$key.="最后一页"; //最后一页
}
$key.='</div>';
?>
<?php echo $key?><br />
<a href="http://192.168.1.143:70/gzl/scym.php">返回主页</a>
</body>
</html>

解决方案 »

  1.   

    把SQL打印出来,就知道了。echo $sql;
    $result=mysql_query($sql);
      

  2.   

    打印后:什么意思啊?Warning: mysql_query() [function.mysql-query]: Access denied for user 'daemon'@'localhost' (using password: NO) in /usr/local/apache/htdocs/ss2.php on line 114Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /usr/local/apache/htdocs/ss2.php on line 114
      

  3.   

    表单由 post 方式改为 get 方式
    <form method="post" action="szym.php">$rql = $_POST[rq];
    改为
    $rql = $_GET[rq];
      

  4.   

    不行啊,把post改为get连第一页都不显示了
    select date(visit_time) as dv,answer_type as atl,count(1) as co from om_log_ask_detail_ group by date(visit_time),answer_type limit 0,15
    Warning: mysql_query() [function.mysql-query]: Access denied for user 'daemon'@'localhost' (using password: NO) in /usr/local/apache/htdocs/ss2.php on line 114Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /usr/local/apache/htdocs/ss2.php on line 1141/0 第一页 上一页 下一页 最后一页
      

  5.   

    你这个地方也改了吗?<form method="get" action="szym.php">