dhlighter Posted December 3, 2011 Share Posted December 3, 2011 The problem is this: When I upload more images, it will create more pages. That works fine, however, It seems when an image get bumped to a new page, it doesn't create a link to that said page. For example, In my Nature/Animals category, I have 5 images in there in total. It should create three pages and links to each page. It created the pages, but only shows "Previous 1 2." There isn't a Next button to page three at all. I have it set to show 2 images per page. So now I need to figure out how to get it right... This is my paging class class paging { public function getPages($pages, $cid, $page_count) { global $db, $SK, $plang, $getURL; $this->pages = $pages; $this->cid = $cid; $this->page_count = $page_count; if(!isset($_GET['section'])) { $page = 1; } else { $page = $_GET['section']; } $prev = $page - 1; $next = $page + 1; $this->render = ''; if($prev > 0){ $this->render .= "<a href='{$getURL['site_url']}index/category/{$this->cid}/$prev'>Previous</a> "; } if($this->pages > 1){ if($pages >= 1 && $page <= $this->pages){ for($x=1; $x<=$this->pages; $x++) { $this->render .= " <a href='{$getURL['site_url']}index/category/{$this->cid}/$x'>$x</a> "; } } } if($page < ceil($this->pages/$this->page_count)){ $this->render .= "<a href='{$getURL['site_url']}index/category/{$this->cid}/$next'>Next </a> "; } return $this->render; } public function pageCount($table, $pid, $field, $page_count) { global $db; $this->pid = $pid; $this->field = $field; $this->page_limit = $page_count; $this->count_query = $db->getCount("SELECT * FROM $table WHERE `$this->field`=$this->pid"); $this->round_cr = ceil($this->count_query) / $this->page_limit; return $this->round_cr; } } And the bit of code that displays the images. public function photoView(){ global $db, $SK, $plang, $PG; $photoid = (int) $_GET['id']; $field = 'catid'; $page_count = 2; $section = (isset($_GET['section']) AND (int)$_GET['section'] > 0) ? (int)$_GET['section'] : 1; if($section) { $page_start = ($section - 1) * $page_count; } else { $page_start = 0; } $start = $PG->pageCount('photos', $photoid, $field, $page_count); if(!empty($photoid)) { $photo_query = $db->query("SELECT * FROM photos WHERE catid='$photoid' ORDER BY `id` DESC LIMIT $page_start, $page_count"); $photo_result = $db->get(); if(count($photo_result) == '') { $this->render .= "No Images to display"; } else { $columns = $this->setresult[0]['colsnum']; $colnum = 2; $this->render .= $SK->photoHeader(); foreach ($photo_result as $pkey => $pvalue) { if($colnum < $columns) { if($colnum == 0){ $this->render .= "<tr>"; } $this->render .= $SK->photoRow($pvalue); } else { $colnum = 0; $this->render .= $SK->photoRow2($pvalue); } $colnum++; } $this->render .= $SK->photoFooter(); $this->render .= "<div style=\"text-align: center;font-weight: bold;\">" . $PG->getPages($start, $pvalue['catid'], $page_count) . "</div>"; } } else { $this->render = "Error: You have chosen the wrong path"; } return $this->render; } You can go to my Nature and Animals category at my site to see the problem Here. You will see the links, but once you go to page 2 there isn't a page three. If you change the 2 to a 3 in the address bar , you will see another image. Like this. You will see that the page links one and two disappear and leaves the previous link... So any idea on what the problem is? I need help -____- Quote Link to comment https://forums.phpfreaks.com/topic/252366-pagination-problem/ Share on other sites More sharing options...
ngreenwood6 Posted December 3, 2011 Share Posted December 3, 2011 Maybe its this line: $this->round_cr = ceil($this->count_query) / $this->page_limit; Should be this: $this->round_cr = ceil($this->count_query / $this->page_limit); Quote Link to comment https://forums.phpfreaks.com/topic/252366-pagination-problem/#findComment-1293808 Share on other sites More sharing options...
dhlighter Posted December 3, 2011 Author Share Posted December 3, 2011 Ok, that worked! But now when you get to the page next to last, the Next link disappears. It shows 1 2 3 next, but when you are on 2, it takes the next link away. Quote Link to comment https://forums.phpfreaks.com/topic/252366-pagination-problem/#findComment-1294049 Share on other sites More sharing options...
scootstah Posted December 3, 2011 Share Posted December 3, 2011 if($page < $this->page_count){ Try this. Quote Link to comment https://forums.phpfreaks.com/topic/252366-pagination-problem/#findComment-1294055 Share on other sites More sharing options...
dhlighter Posted December 3, 2011 Author Share Posted December 3, 2011 nope. same thing. Quote Link to comment https://forums.phpfreaks.com/topic/252366-pagination-problem/#findComment-1294102 Share on other sites More sharing options...
dhlighter Posted December 4, 2011 Author Share Posted December 4, 2011 Nevermind, I figured out the problem. Thanks for all the help! I appreciate it! Quote Link to comment https://forums.phpfreaks.com/topic/252366-pagination-problem/#findComment-1294133 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.