increment=10 //amount of items per page page=whatever //user specified, we read this in max=page*increment //the highest item number that will be shown on any page (eg, 10 for page 1) min=max-increment items=[all inputs read in and processed and whatever. in some kind of array type structure] total_items=count(items) max_page=round up (total_items/increment) for(int i=min; i++; i<=max) { output items[i] } for(int i=1; i++; i<=max_page} { if (i == page) outout page number //no link if it's the current page else output (link page) }