如果当前页为2的话,下面的地址中的p就显示1和3,如果当前页为10的话,p的值就为9和11,如果要用PHP语句来实现的话,该怎么写啊??????
var lefturl= 'http://cq.qq.com/a/20120619/000067.htm#p=1';
var righturl= 'http://cq.qq.com/a/20120619/000067.htm#p=3';
var lefturl= 'http://cq.qq.com/a/20120619/000067.htm#p=1';
var righturl= 'http://cq.qq.com/a/20120619/000067.htm#p=3';
index.php?m=content&c=index&a=show&catid=8&id=2#1就是PHPCMS组图后面有个#号,#号后面有个数字,如何得到上一张图片和下一张图片的值。
$url = array();
if($p <= 1){//当处于首页时
$url['lefturl']= 'http://cq.qq.com/a/20120619/000067.htm#p=1';
$url['righturl']= 'http://cq.qq.com/a/20120619/000067.htm#p='.($p+1);
}elseif($p > 1 && $p < $totalPage){
$url['lefturl']= 'http://cq.qq.com/a/20120619/000067.htm#p='.($p-1);
$url['righturl']= 'http://cq.qq.com/a/20120619/000067.htm#p='.($p+1);
}elseif($p >= $totalPage){//当处于尾页时
$url['lefturl']= 'http://cq.qq.com/a/20120619/000067.htm#p='.($p-1);
$url['righturl']= 'http://cq.qq.com/a/20120619/000067.htm#p='.$totalPage;
}
return $url;
}
我觉得你包成个函数直接调用比较好,$totalPag是总页数,$p是当前页码
返回一个数组,$url['lefturl']上一页地址,$url['righturl']下一页地址。
使用地址的时候 <a href="<?php echo $url['lefturl']; ?>">上一页</a>
<a href="<?php echo $url['righturl']; ?>">下一页</a>
我记得在哪个网站看到过。