下一页/上一页按钮<a> build with $_GET

时间:2015-12-10 13:44:20

标签: php html

I have an html webpage with a next and previous button. The url for the button is different for each page you are already on. The code for the next page is like this

<a href='<?=$_GET['1'];?>/<?=$_GET['2'];?>/<?=$_GET['3']+1;?>'>Next</a>    
<a class=href='<?=$_GET['1'];?>/<?=$_GET['2']/<?=$_GET['3']-1;?>;?>'> Previous</a>

the url is like www.website.com/text1/text2/number

text1 is what u get with GET['1'] 

text2 is what u get with GET['2]

You get the number with GET['3']

It is working perfectly in all browsers except in Internet Explorer. I have already meta http-equiv="content-type" content="text/html; charset=UTF-8" in my header

But in IE when you hit the button (no matter wich one) it will make something like www.website.com/text1/text1/text2/text2/number

3 个答案:

答案 0 :(得分:0)

也许你呢?在这里你计算第二个参数

<a class='' href='<?=$_GET['1'];?>/<?=(($_GET['2']/$_GET['3'])-1);?>'> Previous</a>

还是那个?在这里链接到几个子目录

<a class='' href='<?=$_GET['1'];?>/<?=$_GET['2'];?>/<?=($_GET['3']-1);?>'> Previous</a>

答案 1 :(得分:0)

如果不是在锚标记中创建网址,那么

会不会更容易
$p1 = $_GET['1'];
$p2 = $_GET['2'];
$p3 = intval($_GET['3']);
$pPrev = intval($p3 - 1);
$pNext = intval($p3 + 1);

$prevUrl = $p1 . "/" . $p2 . "/" . $pPrev;
$nextUrl = $p1 . "/" . $p2 . "/" . $pNext;
<a href='<?php echo $nextUrl; ?>'>Next</a>    
<a href='<?php echo $prevUrl; ?>'> Previous</a>

它应解决您在解析网址中的第三个参数时遇到的错误。

答案 2 :(得分:0)

尝试在href。

中填写所需网页地址的完整链接

例如

<a href="http://www.website.com/<?=$_GET['1'];?>/<?=$_GET['2'];?>/<?=($_GET['3']-1);?>"> Previous</a>