Advertisement
ExeQue

Untitled

Mar 30th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 KB | None | 0 0
  1. <?php
  2.  
  3. $arr = array_merge(\Models\Device::getUserDevices(), \Models\Device::getUserDevices(23));
  4.  
  5.  
  6. $max = 3;
  7.  
  8. $p = filter_input(INPUT_GET, "p", 519);
  9. $length = count($arr);
  10.  
  11. $pages = ceil($length / $max);
  12.  
  13. if (!is_null($p) && strlen($p) > 0 && !(intval($p) > $pages)) {
  14.     $page = intval($p) >= 1 ? intval($p) - 1 : 0;
  15.     for ($i = $page * $max;
  16.          $i < ($page * $max) + $max && $i < $length;
  17.          $i++) {
  18.  
  19.         dump($arr[ $i ]->description);
  20.  
  21.  
  22.     }
  23.  
  24.     $html = "";
  25.  
  26.     $pages = ceil($length / $max);
  27.     for ($i = $p - $max <= 0 ? 1 : $p - $max;
  28.          $i <= $pages && $i < ($p + $max + 1 >= $length ? $length : $p + $max + 1);
  29.          $i++) {
  30.         $bold = $i == $p ? "bold" : "normal";
  31.         $html .= "<a class='btn btn-default' href='?p=$i' style='font-weight: $bold'>$i</a>";
  32.     }
  33.  
  34.     echo "<a class='btn btn-default' href='?p=1'><-</a>" . $html . "<a class='btn btn-default' href='?p=$pages'>-></a>";
  35.  
  36. } else {
  37.     echo "NO!";
  38. }
  39.  
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement