This website mostly serves to present my work as an webdesigner. In my portfolio you will find an overview of my recent projects.

Anleitung zum löschen des Cache: cachemeifyoucan.com

markuslang.com

bigr-solutions.net

musikwerker.de

projekt-misside-guinea.de

feedyourfeeds.com

 

 

Paging your content dynamicly

Do you need a function for paging your content? Feel free to use this php code for your application.
If you know any tips to improve let me know.

  1. function paging($m, $u, $p) {
  2.   if ($m > 1) {
  3.     if ($p == "") $p = 1;
  4.     for ($i=$p-$u; $i<=$p+$u; $i++) {
  5.       if ($i == $p-$u) {
  6.         if ($p == 1) $strResult .= '1 ';
  7.         else $strResult .= '<a href="?p=1" class="p">1</a> ';
  8.         if ($p-$u > 2) $strResult .= '... ';
  9.       }
  10.       if ($i < $m && $i != 1 && $i > 0) {
  11.         if ($i == $p) $strResult .= $i.' ';
  12.         else $strResult .= '<a href="?p='.$i.'" class="p">'.$i.'</a> ';
  13.       }
  14.       if ($i == $p+$u) {
  15.         if ($i < $m-1) $strResult .= ' ... ';
  16.         if ($p == $m) $strResult .= $m.' ';
  17.         else $strResult .= '<a href="?p='.$m.'" class="p">'.$m.'</a>';
  18.       }
  19.     }
  20.   }
  21.   return $strResult;
  22. }

 

Download the code here.

 

Example:

 

2 Responses to “Paging your content dynamicly”


  1. baldo

    is that for wp?


  2. Ronny Engelmann

    I´m sorry, it´s only the code for an integration in your web application, not a plugin for wordpress. To use the paging-code, you have to generate three variables: the number of the pages, the count of pages before and after the current page and the current page itself.


Leave a Reply