Jump to content

Pagination problem


dhlighter

Recommended Posts

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 -____-

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.