pagination header for dynamic website

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mkmagloire
Forum Newbie
Posts: 1
Joined: Wed Sep 02, 2015 4:12 am

pagination header for dynamic website

Post by mkmagloire »

Greetings,

I'm really new in programming stuffs, you help is more than welcome.
I have a concern and I'm still not able to sort it out until now.
I'd like to create seo pagination for website's results page, and have it into the html header.
The problem is, I'm not really able to do it as the previous developer choose to use javascript: void(0) instead. I'd like to change it.
Here is the current code:

Code: Select all

$total_page = ceil($total/$perpage);
    $startpoint = ($page * $perpage) - $perpage;
    $lim = 5;
    $link = 'javascript:void(0);';
    $pdata = '<div class="pg2_pagnation" style="float:right">'.pagination_front($page,$total_page,$link,$lim).'</div>';
The output of the page is:

123 Next or Previous 12345 Next. (While having the cursor on the pagination, the shows javascript:void(0))
However, I'm facing some issues with my javascript, so, would prefer to avoid that and to have a proper link on the pagination.
I'd like to better have some thing like: http:www.example/cars/page1, http:www.example/cars/page2, http:www.example/cars/page3, ... http:www.example/cars/page10 (last page) instead.

Also, regarding the header, I'd like to use the pagination for some seo purposes and have:

Code: Select all

<link rel="canonical" href="https://www.example.com/page1">
    <link rel="prev" href="https://www.example.com/page2">
    <link rel="next" href="https://www.example.com/page4">


Thanks in advance for your time and your contribution.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: pagination header for dynamic website

Post by social_experiment »

I'll explain assuming that you are retrieving records from a database and want to paginate those; you have to page along the amount of elements per page and the starting point for the next set of records. The url might look like this: www.example.com?s=5&ipp=5 (s is the starting point from where you select and ipp is the amount of items per page.

Below is a link that you can have a look at, (if you haven't already googled)
http://www.tutorialspoint.com/php/mysql_paging_php.htm

hth
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply