Jump to content

help with next and previous page script


calmchess

Recommended Posts

The following script changes pages based on a link being clicked. The forward link works well but the back link doesn't function as exspected...I'm hoping somebody will help me straighten out this script and make it work properly. If you want to execute the script just throw it in a web page and it will execute on my webserver.

 

<html>
<head>
<title>next page</title>

</head>
<body>
<?php

if(isset($_GET['pg'])){

$pnum1 =$_GET['pg'];
}else{

$pnum1=0;


}

if(isset($_GET['rnum'])){

$rnum =$_GET['rnum']+1;

}else{

$rnum=0;
$pnum = 0;
$sp =0;

}

$pnum =$rnum;
$sp = $rnum;
if(isset($_GET['rnum'])){
   $t1=($rnum-1);
  
     
   
   if($t1==10){
   $rnum=10;
   } 

}
if(isset($_GET['rnum'])){

$t=($rnum-1-1);

if($t==-1){
$t=$t+1;
$rnum1 = $rnum-1;
        echo "self";

	echo "<a href=\"http://privatechatnow.com/currentwebsite/4pic/next$rnum1.php?rnum=$rnum&pg=$t;\"><<</a> &nbsp $t &nbsp";

}else{
$rnum1 = $rnum-1;
echo "tracing T ".$t;

	echo "<a href=\"http://privatechatnow.com/currentwebsite/4pic/next$rnum1.php?rnum=$t&pg=$t\"><<</a>&nbsp pg.$t &nbsp";

     	
}


}



if($rnum==0){

echo "<a href=\"http://privatechatnow.com/currentwebsite/4pic/next$sp.php?rnum=$rnum&pg=$rnum\">>></a>&nbsp";

}else{
echo "<a href=\"http://privatechatnow.com/currentwebsite/4pic/next$sp.php?rnum=$rnum&pg=$rnum\">>></a>&nbsp";
}
?>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/166254-help-with-next-and-previous-page-script/
Share on other sites

here is the solution if anybody is intrested.

 


<html>
<head>
<title>next page</title>

</head>
<body>
<?php

if(isset($_GET['rnum'])){

$rnum =$_GET['rnum']+1;
$dis = $rnum-1;
$ctrl=0;
}else{
   $ctrl=0;

$rnum=1;
$pnum =1;
$sp =1;
$dis = 0;

}

if(isset($_GET['pg'])){

$pnum1 =$_GET['pg'];
}else{

$pnum1=0;


}



$pnum =$rnum;
$sp = $rnum;
if(isset($_GET['rnum'])){
   $t1=($rnum-1);
  
     
   
   if($t1==10){
   $rnum=10;
   } 

}
if(isset($_GET['rnum'])){

$t=($rnum-1-1);

if($t==-1){
$t=$t+1;
$rnum1 = $rnum-2;
$ctrl =1;
if($dis ==0){
    
        echo "<a href=\"\"onClick\"return false\"\"><<</a> &nbsp pg.$dis &nbsp";

        }else{

	echo "<a href=\"http://privatechatnow.com/currentwebsite/4pic/next$pnum1.php?rnum=$rnum&pg=$t\"><<</a> &nbsp pg.$dis &nbsp";
	}
}else{
$rnum1 = $rnum-2;

	echo "<a href=\"http://privatechatnow.com/currentwebsite/4pic/next$rnum1.php?rnum=$t&pg=$t\"><<</a>&nbsp pg.$dis &nbsp";

     	
}


}



if($rnum==1 && $ctrl==0){

echo "<a href=\"\" onclick=\"return false\"><<</a>  pg.$dis  <a href=\"http://privatechatnow.com/currentwebsite/4pic/next$sp.php?rnum=$rnum&pg=$rnum\">>></a>";


}else{
echo "<a href=\"http://privatechatnow.com/currentwebsite/4pic/next$sp.php?rnum=$rnum&pg=$rnum\">>></a>&nbsp";
}
?>

</body>
</html>

here is some bug fixes.

 


<html>
<head>
<title>next page</title>

</head>
<body>
<?php

if(isset($_GET['rnum'])){

$rnum =$_GET['rnum']+1;
$dis = $rnum-1;
$ctrl=0;
}else{
   $ctrl=0;

$rnum=1;
$pnum =1;
$sp =1;
$dis = 0;

}

if(isset($_GET['pg'])){

$pnum1 =$_GET['pg'];
}else{

$pnum1=0;


}



$pnum =$rnum;
$sp = $rnum;
if(isset($_GET['rnum'])){
   $t1=($rnum-1);
   if($t1==10){
   
   } 
  

}
if(isset($_GET['rnum'])){

$t=($rnum-1-1);

if($t==-1){
$t=$t+1;

$rnum1 = $rnum-2;
$ctrl =1;
if($dis ==0 ){
    
        echo "<a href=\"\"onClick\"return false\"\"><<</a> &nbsp pg.$dis &nbsp";

        }else{

	echo "<a href=\"http://privatechatnow.com/currentwebsite/4pic/next$pnum1.php?rnum=$rnum&pg=$t\"><<</a> &nbsp pg.$dis &nbsp";
	}
}else{
$rnum1 = $rnum-2;

	echo "<a href=\"http://privatechatnow.com/currentwebsite/4pic/next$rnum1.php?rnum=$t&pg=$t\"><<</a>&nbsp pg.$dis &nbsp";

     	
}


}



if($dis==10){

//echo "<a href=\"\" onclick=\"return false\"><<</a>  pg.$dis  <a href=\"http://privatechatnow.com/currentwebsite/4pic/next$sp.php?rnum=$rnum&pg=$rnum\">>></a>";

echo "<a href=\"\" onclick=\"return false\" \">>></a>&nbsp";
}else{
echo "<a href=\"http://privatechatnow.com/currentwebsite/4pic/next$sp.php?rnum=$rnum&pg=$rnum\">>></a>&nbsp";
}
?>

</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.