Any ideas on how this has been accomplished?

-fedexer-

New Member
Messages
32
Reaction score
0
Points
0
Ok on this site: http://www.moparscape.org/serverstatus.php?start=0

I was wondering how using PHP the creator of this site manages to list only 30 servers per page, and if there are more, then they add another page to the list at the bottom?
Pages: [1] 2 3 4 ... 15

Has anyone got any ideas on how this could be acheived? i reckon mysql_num_rows(); plays a part.. but i am unsure how.

If someone could create an example piece of code , that would be great. Or just makes a suggestion.

-fedexer-
 

konekt

New Member
Messages
100
Reaction score
0
Points
0
Well, let's consider certain things. The first is how the data is transfered. The URL tells us the following:
http://www.moparscape.org/serverstatus.php?start=x

Where x is 30*(n-1) and n is the nth page you are on.
So for page 1, you have 30*0... and start=0
page 2 you have 30*1... and start = 30

So, we can reverse that algorithm. Assuming that he is using mysql to store the pages, you can dynamically add the links to the bottom by doing something like:
$rows = mysql-query-to-get-rows

for($i=0; $i<floor($rows/30); $i++)
//write $i as link where href = phppage?show=30*($i-1)

Then depending on the show you can set the query as;
get-from-mysql- rows show->show+30.

That's they theory behind it. I wasn't sure if you wanted actual code.
 
Last edited:

-fedexer-

New Member
Messages
32
Reaction score
0
Points
0
That makes sense, thanks alot konekt, i would never have guessed that (my reasoning skills in mathematics is not great (as per my exam results tell me))

Thanks again
-fedexer-
 
Last edited:
Top