Jump to content

Paging problems


Ifaiden

Recommended Posts

I've just managed to get my paging function to work. Here's how it works:

From mysql's "LIMIT $X,$Y", X is the starter and Y is the limit, and the limit is a constant digit.

For example: If I define the limit as  $Y=2 and $X=0 only two rows will appear and its the first two rows. And if there is 10rows in total, it will display the paging as 1, 2, 3, 4, 5.

---

My problem is, if there are like over 10 000 rows it will display from 1, 2, 3, 4...etc to 5000 in in the paging. I want it to display just like in this forum. like this: 1, 2, 3, 4, [...], 5000. (the closest three pages of the current page, and the last page)

 

Another example. If 10is the current page:

7, 8, 9, 10, 11, 12, 13, [...], 5000

---

Any idea how to make this work? (sorry for the poor explanation) 

 

Link to comment
https://forums.phpfreaks.com/topic/197148-paging-problems/
Share on other sites

Oh thanks... but I still can't get it to work, please help me, here's my code:

 

echo "Number News:" .$nume. "<br>";
echo "Start:" .$eu. "<br>";
echo "Limit:" .$limit. "<br>";
echo "Page:" .$page. "<br>----<br>";
$l=1;
$i=0;

for($i=0; $i < $nume; $i=$i+$limit){ 
	if($i <> $eu ){
	echo "<a href='$page_name&start=$i&limit=$limit'><font face='Verdana' size='2'> $l</font></a> ";
        }

                 else {
                 echo "<font face='Verdana' size='4' color=red>$l</font>"; //The current page is red
                 } 
         $l++;
      }

 

And this displays:

Number News: 22

Start: 0

Limit: 2

Page: 1

 

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11

---

I want it to look like this: 1, 2, 3, [...], 11

 

Link to comment
https://forums.phpfreaks.com/topic/197148-paging-problems/#findComment-1035264
Share on other sites

Changed the code a little bit, still won't work. Can someone please help?

 

$l=1;
$i=0;

$how_much_before = 2;
$how_much_after = 2;


for($i= 0; $i < $nume; $i=$i+$limit){

if($page == $l){ //The current site is not displayed as a link and is highlighted with the color red
	echo "<font face='Verdana' size='4' color=red>$l</font>";
	}
else {
	echo "<a href='$page_name&start=$i&limit=$limit'><font face='Verdana' size='2'> $l</font></a> ";
	}
$l++;

}

Link to comment
https://forums.phpfreaks.com/topic/197148-paging-problems/#findComment-1035407
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.