php - Why counter resets when I click on other link? -


i have define counter in while loop , initialized outside loop.

i have echo counter in loop itself. when have 50 record on first page displays 1 25. problem on second page start again 1, not should work: start 26 50.

here code:

        <?php         //show records         $query = mysqli_query($con,"select table2.col2 a,table1.col2   b, table1.col1 c, table1.q_url d {$statement} limit {$startpoint} ,   {$limit}");         $authorname='';         $count=1;         while ($row = mysqli_fetch_array($query)) {           $output='';         $authorname =$row['a'];           $url = "http://$_server[http_host]$_server[request_uri]";           $url=explode('/',$url);           ?>         <div class="record round"><?php echo  $count;$output .='<a     href="http://localhost/quotes/'.$url[5].'/'.$row['d'].'.html">';          echo $output .=$row['b'].'</a>';?></div>           <?php            $count++;           }         ?>  

edit try

$nbpage = 2; $nbresultperpage=25;  $count = ($nbpage-1)*$nbresultperpage; 

where $nbpage you're current number of page


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -