Home > Backend Development > PHP Tutorial > ,困扰了小弟我很长时间的分页有关问题

,困扰了小弟我很长时间的分页有关问题

WBOY
Release: 2016-06-13 13:22:17
Original
971 people have browsed it

求助,困扰了我很长时间的分页问题
我的分页定值是是显示正常的,翻页显示正常,但一旦赋值(我希望别人输入日期,可以自动去找那个月的资料),就不行了,第一页是正常的,第二页就开始无法正常显示了,我觉得大概是值没有传到下一页,但我不会改啊~求大家帮忙
经理开始没耐心了~我快疯了,

输入日期页面,scym.php


日期






数据日期格式(如:201206)



请输入日期:











显示页面,szym.php





数据



include("conn.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']$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 "

" ."数据资料($rql)". "

";

echo "




";

while($row = mysql_fetch_array($result))
{
echo "";
echo "";
echo "";
echo "";
echo "";
}

echo "
日期 回答类型 数量
" . $row['dv'] . "" . $row['atl'] . "". $row['co'] . "
";

mysql_close($con);

?>


$page_len = ($page_len%2)?$page_len:$pagelen+1;//页码个数
$pageoffset = ($page_len-1)/2;//页码个数左右偏移量

$key='
';
$key.="$page/$pages "; //第几页,共几页
if($page!=1){
$key.="第一页 "; //第一页
$key.="上一页"; //上一页
}else {
$key.="第一页 ";//第一页
$key.="上一页"; //上一页
}
if($pages>$page_len){
//如果当前页小于等于左偏移
if($page$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;$iif($i==$page){
$key.=' '.$i.'';
} else {
$key.=" ".$i."";
}
}
if($page!=$pages){
$key.=" 下一页 ";//下一页
$key.="最后一页"; //最后一页
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template