pulling page count in url pagination
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.
&page=<?php if(isset($_GET['page'])) { echo ($_GET['page'] + 10);} ?>
so what if $_GET['page'] is not set?
精彩评论