Hello, Here is the code I'm currently using. When I click next, the page just reloads and the same content is still being displayed. I will break it down from PHP to HTML.
There is the PHP.Code:$maxRows_getRecent = 8; $pageNum_getRecent = 0; if (isset($_GET['pageNum_getRecent'])) { $pageNum_getRecent = $_GET['pageNum_getRecent']; } $startRow_getRecent = $pageNum_getRecent * $maxRows_getRecent; mysql_select_db($database_XXX, $XXX); $query_getRecent = "SELECT news.post_id, news.title, news.category, news.link, news.picture, news.preview FROM news WHERE news.category NOT IN (SELECT news.category FROM news WHERE news.category='random' )ORDER BY news.updated DESC"; $getRecent = mysql_query($query_getRecent, $XXX) or die(mysql_error()); $row_getRecent = mysql_fetch_assoc($getRecent); $totalRows_getRecent = mysql_num_rows($getRecent); if (isset($_GET['totalRows_getRecent'])) { $totalRows_getRecent = $_GET['totalRows_getRecent']; } else { $all_getRecent = mysql_query($query_getRecent); $totalRows_getRecent = mysql_num_rows($all_getRecent); } $totalPages_getRecent = ceil($totalRows_getRecent/$maxRows_getRecent)-1; $queryString_getRecent = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_getRecent") == false && stristr($param, "totalRows_getRecent") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_getRecent = "&" . htmlentities(implode("&", $newParams)); } } $queryString_getRecent = sprintf("&totalRows_getRecent=%d%s", $totalRows_getRecent, $queryString_getRecent); ?>
Here is the HTML.
This is what I have at the moment. I would like to be able to create paging for this but not have the entire page reload if that is at all possible. To have only a section of the page refresh as it scrolls through the pages. I would like to give my thanks in advance and if you need more information from me please don't hesitate to ask. I will give you more code or information as needed. Thank you.Code:<?php do { ?> <article> <div id="picture"><a href="<?php echo $row_getRecent['post_id']; ?>/<?php echo urlencode($row_getRecent['title']); ?>.html"><img src="<?php echo $row_getRecent['picture']; ?>" width="250" alt="" /></a> <div id="category"><h2 id="cat"><a href="<?php echo $row_getRecent['category']; ?>.php"><?php echo $row_getRecent['category']; ?></a></h2></div></div> <div id="info"> <h1 id="title"><a href="<?php echo $row_getRecent['post_id']; ?>/<?php echo urlencode($row_getRecent['title']); ?>.html"><?php echo $row_getRecent['title']; ?></a></h1> <p><?php echo $row_getRecent['preview']; ?></p> <div id="commentlink"><h6><a href="fetch.php?id=<?php echo $row_getRecent['post_id']; ?>#disqus_thread">Link</a></h6></div></div></article> <?php } while ($row_getRecent = mysql_fetch_assoc($getRecent)); ?> <div id="paging"> <div class="page"><?php if ($pageNum_getRecent > 0) { // Show if not first page ?> <a href="test.php?id<?php printf("%s?pageNum_getRecent=%d%s", $currentPage, 0, $queryString_getRecent); ?>">First</a> <?php } // Show if not first page ?></div> <div class="page"><?php if ($pageNum_getRecent > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_getRecent=%d%s", $currentPage, max(0, $pageNum_getRecent - 1), $queryString_getRecent); ?>">Previous</a> <?php } // Show if not first page ?></div> <div class="page"><?php if ($pageNum_getRecent < $totalPages_getRecent) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_getRecent=%d%s", $currentPage, min($totalPages_getRecent, $pageNum_getRecent + 1), $queryString_getRecent); ?>">Next</a> <?php } // Show if not last page ?></div> <div class="page"><?php if ($pageNum_getRecent < $totalPages_getRecent) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_getRecent=%d%s", $currentPage, $totalPages_getRecent, $queryString_getRecent); ?>">Last</a> <?php } // Show if not last page ?></div> </div>


Reply With Quote

Bookmarks