Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770
Форумы портала PHP.SU :: Версия для печати :: Не получается пагинация страниц.
Форумы портала PHP.SU » » Вопросы новичков » Не получается пагинация страниц.

Страниц (1): [1]
 

1. leshiy - 10 Декабря, 2017 - 15:45:31 - перейти к сообщению
Все работает нормально но только до второго клика по нумерации.
PHP:
скопировать код в буфер обмена
  1. <?PHP
  2. include 'config.php';
  3. include 'functions.php';
  4. $count_statti = get_count_statti();
  5. $number_pages = number_pages($count_statti,COUNT_PER_PAGE);
  6. if($_GET['page']){
  7.     $page = (int)$_GET['page'];
  8.     if(!page){
  9.         $page = 1;
  10.     }
  11. }else{$page = 1;}
  12. $result = get_posts($count_statti,$page,COUNT_PER_PAGE);
  13. if($_GET['move'] == 1){
  14.         foreach($result as $row){
  15.         printf("<p>%s</p><p>%s</p>",$row["id"],$row["title"]);
  16.     }
  17.             for($i = 1; $i <= $number_pages; $i++){
  18.             if ($i < $page+8  and $i > $page-0){
  19. printf("<li id='%s'>%s</li>",$i,$i);
  20.         }}
  21. exit();
  22. }
  23. ?>
  24.  

CODE (javascript):
скопировать код в буфер обмена
  1.  
  2. <script type="text/javascript">
  3. $(document).ready(function(){
  4.     $(".load").hide();
  5. $(".wrap li").click(function(){
  6.             var id = $(this).attr('id');
  7.              $(".load").fadeIn(100,function(){
  8.       $.ajax({
  9.       url:'index.php',
  10.       type:'GET',
  11.       data: "page="+id+"&move=1",
  12.       success: function(html){
  13.       $(".load").fadeOut(100,function(){
  14.      $(".main_text").html(html).hide().fadeIn(100);
  15.       });
  16.   }
  17.   });
  18.   });
  19.     });
  20.  });
  21. </script>
  22.  

<div class="wrap">
<div class="content">
<div class="load"></div>
<div class="main_text">
PHP:
скопировать код в буфер обмена
  1. <?PHP
  2.     foreach($result as $row){
  3.         printf("<p>%s</p><p>%s</p>",$row["id"],$row["title"]);
  4.     }
  5.             for($i = 1; $i <= $number_pages; $i++){
  6.             if ($i < $page+8  and $i > $page-0){
  7. printf("<li id='%s'>%s</li>",$i,$i);
  8.         }}
  9. ?>

</div>
</div>
</div>
2. 3d_killer - 19 Декабря, 2017 - 10:03:40 - перейти к сообщению
то есть ты обновляешь main_text и там же находится пагинация?

 

Powered by ExBB FM 1.0 RC1