Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $arr = array_merge(\Models\Device::getUserDevices(), \Models\Device::getUserDevices(23));
- $max = 3;
- $p = filter_input(INPUT_GET, "p", 519);
- $length = count($arr);
- $pages = ceil($length / $max);
- if (!is_null($p) && strlen($p) > 0 && !(intval($p) > $pages)) {
- $page = intval($p) >= 1 ? intval($p) - 1 : 0;
- for ($i = $page * $max;
- $i < ($page * $max) + $max && $i < $length;
- $i++) {
- dump($arr[ $i ]->description);
- }
- $html = "";
- $pages = ceil($length / $max);
- for ($i = $p - $max <= 0 ? 1 : $p - $max;
- $i <= $pages && $i < ($p + $max + 1 >= $length ? $length : $p + $max + 1);
- $i++) {
- $bold = $i == $p ? "bold" : "normal";
- $html .= "<a class='btn btn-default' href='?p=$i' style='font-weight: $bold'>$i</a>";
- }
- echo "<a class='btn btn-default' href='?p=1'><-</a>" . $html . "<a class='btn btn-default' href='?p=$pages'>-></a>";
- } else {
- echo "NO!";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement