I've been trying to work out how to add a "X entries per page" feature, where the number X could be changed by the user to suit his own needs.
As it is now, I have a while loop that runs through an array that contains all NPCs, and prints to a table.
Ignore the NPC names, I've not implemented a way of generating different names yet :p
The problem here is that I need page one to show the 25 first entries in the array on page one, 26-50 on page 2, and so on until last item is shown.
I've fiddled some with the code layout shown below, which enables me to print only the first 25 entries, but the problem starts with the "next page", where I need to print entries 26 through 50 etc.
Code: Select all
$npc_data = getAllNPCs();
$counter = 0;
$row_limit = 25;
while($rows = mysql_fetch_array($npc_data)) {
// set up local variables to fetch current array data
$counter++;
// Print fetched data to a HTML table
if($counter % $row_limit == 0) {
// stop printing, we've reached the row limit
}
}