HREF JQUERY CYCLE [closed]

0

I need a cycle in jquery where I am referencing different pages and the variable is increasing.

Example

setTimeout(function(){
<?php
$b=1;
?>

   location.href="paging.php?page=<?php echo $b?>"

 <?php $B++?>
    } , 2000); 
</script>

I've tried it like that but it does not increase it just shows always the same page.

THANK YOU.

    
asked by Andrés Hernandez 22.05.2016 в 23:03
source

1 answer

2

The problem is that you are re-initializing the variable to 1 in each page reload in the setTimeout function.

A better version would be

setTimeout(function(){

  <?php
    if ($_GET['page']){
      $b=1;
    } else {
      $b = (int)($_GET['page']) + 1;
    }
  ?>

  location.href="paging.php?page=<?php echo $b?>"


} , 2000); 

    
answered by 23.05.2016 в 00:55