页数在php分页中不起作用 [英] pages numbers didn't effect in php paging

查看:95
本文介绍了页数在php分页中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我有要在其上应用分页的php页面,但是有一个问题,例如,当我选择第2页时,它没有任何意义,并且在显示新数据方面没有任何效果.加上我有两个下拉列表,当我更改页面编号时,这些列表中的所选项目将采用默认格式,而不是我所做的所选内容.
这是您的代码,请帮忙,因为我不太了解php

hi all
i have php page that i want to apply paging on it , but there is a problem, when i choose page no 2 for example , it has no sense and there is no effect in displaying new data. plus to this that i have two drop down list , when i change the page no , the selected items of these list go the default form not to the selected i have made.
here you are my code , any help please as i don''t know php well

if(isset ($_GET['kat']))
          {
          $subkat=$_GET['kat'];
          $mainkat=$_GET['mainkat'];
          $qmainkat="where maincategory='$mainkat'"; 
          $qkat=$qmainkat." and category='$subkat'";
          echo "<br>[<a href='adm_shop_add.php'>">ADD NEW</a>]";
          
          
          
          $qsh="select * from shop_item $qkat order by postdate desc ";
          $rs_sh=@mysql_query($qsh);
          $ada_sh=@mysql_num_rows($rs_sh);
          if ($ada_sh>0){ 
          if(isset($_GET['page']))
          {
           $pageNum = $_GET['page'];
          }
          else
          {
          $pageNum = 1;
          }
          $offset = ($pageNum - 1) * $rowsPerPage;
          $result=@mysql_num_rows(@mysql_query("select id from shop_item $qkat"));
       
          $query   = "SELECT COUNT(id) AS numrows from shop_item $qkat ";                      
          $result  = mysql_query($query) or die('Error, query failed');
          $row     = mysql_fetch_array($result, MYSQL_ASSOC);
          
          
          $numrows = $row['numrows'];
          
          
          $maxPage = ceil($numrows/$rowsPerPage);
            
          
          $self = $_SERVER['PHP_SELF'];
          $nav  = '';
          for($page = 1; $page <= $maxPage; $page++)
          {
            if ($page == $pageNum)
            {
            $nav .= " $page "; // no need to create a link to current page
            }
            else
            {
             $nav .= " <a href=\"$self?page=$page\">$page</a> ";
            }
         }
         // print the navigation link
         echo $first . $prev . $nav . $next . $last;        
          
          echo "<table border=0 cellpadding=8 cellspacing=8 >";
          echo "<tr>";
          while ($ro_sh=@mysql_fetch_array($rs_sh))
          {
          $row++;
          echo "<td valign=top align=center >";
         if (!empty($ro_sh[picture]))
         {
            echo "<img src='".$ro_sh[picture]."' border=0 width=120>";
         }         
         echo "</td>";
         echo "<td valign=top >";
         $kategoriname=@mysql_result(@mysql_query("select name from shop_kat where id='$ro_sh[category]'"),0,0);
         echo "".$ro_sh[title]."";
         echo "<br><small>".$ro_sh[description];    
         
         echo "</td>";
          echo "</tr>";
          echo "<tr>";
          }
          echo "</tr>";        
          echo "</table>";
          
          }
          }



感谢



thanks

推荐答案

_GET [' kat'])) {
_GET['kat'])) {


subkat =


_GET ['
_GET['kat'];


这篇关于页数在php分页中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆