duanlumei5941 2011-08-30 17:22
浏览 54
已采纳

在网页分页中提取页数

I have a social network that has a blogs and questions section. There are community pages for each one ( blogs/questions ) On each of those pages. the first ten blogs/questions are displayed. To the right of those are a list of clickable categories that sort the pages according to their category.

I have pagination implemented after each ten. I am doing a mod_rewrite for pretty urls on my dev and have everything working correctly. The problem is, after hitting next the first time 'page=' is blank and just reloads the first (defaulted page) but after a second click it becomes 'page=10' as it should and then the third click 'page=20" as it should.

So basically I am trying to get it to go to 'page=10" after one click, not two. Here is the code for the pagination:

<div id="all_page_turn">
                         <ul>

                            <?php if($totalBlogs > 10 && $_GET['page'] >= 10) { ?>
                             <li class="PreviousPageBlog round_10px">
                                 <a href="/blogs/?cat=<?php if(isset($_GET['cat'])) { echo $_GET['cat'];} ?>&sort=<?php if(isset($_GET['sort'])) { echo $_GET['sort'];} ?>&page=<?php if(isset($_GET['page'])) { echo ($_GET['page'] - 10);} ?>">Previous Page</a>
                             </li>
                             <?php } ?>

                               <?php if($totalBlogs > 10 && $_GET['page'] < ($totalBlogs-10)) { ?>
                             <li class="NextPageBlog round_10px">
                                 <a href="/blogs/?cat=<?php if(isset($_GET['cat'])) { echo $_GET['cat'];} ?>&sort=<?php if(isset($_GET['sort'])) { echo $_GET['sort'];} ?>&page=<?php if(isset($_GET['page'])) { echo ($_GET['page'] + 10);} ?>">Next Page</a>
                             </li>
                             <?php } ?>



                         </ul>
        </div>

</div>

and here is the defaulted category link:

<div id="RightBlogs">
        <div id="search_blogs_future" class="round_10px">
        <form name="searchBlogs" action="/blogs" method="get">
            <input type="text" name="BlogSearch" class="text" value="<?php if(empty($_GET['BlogSearch'])) { echo "Search Blogs"; }else{ echo $_GET['BlogSearch'];} ?>" onclick="clearify(this);" />
             <input type="submit" name="subBlogSearch" value="Search" />
         </form>
     </div>
     <div class='<?php if(empty($_GET['cat']) || $_GET['cat'] == "All") { echo "all_blog_cats_Highlighted"; }else{ echo "all_blog_cats_unHighlighted"; } ?> round_10px'>
         <a href='/blogs/?cat=All'>
                 All
                 </a>
          </div>

Here is a screen shot of the page, as I'm on my dev so I can't provide a link. you can't see the "next" button, but it's there on the bottom, and then the categories are on the right.

enter image description here

  • 写回答

1条回答 默认 最新

  • douliao8760 2011-08-30 17:43
    关注
    &page=<?php if(isset($_GET['page'])) { echo ($_GET['page'] + 10);} ?>
    

    so what if $_GET['page'] is not set?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用三极管设计一个单管共射放大电路
  • ¥20 fluent无法启动
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架