I went with a database solution in the end but the method to display the output would've been the same - here's the final code:
print '<table class="tborder" border="0" width="95%" align="center">';
$t=0;
print '<tr>';
while ($data=mysql_fetch_array($result)) {
// include code to display results as you see fit
$t++;
print '<td align="center">';
print "<a href=\"" .$data['link']."\" title=\"Add An Image - Link No. ".$data['linknum']."\"><img src=\"phpThumb.php?src=" .$data['link']. "&w=100\"></a><br>";
print "submitted by<br>";
print $data['name']."<br>";
print $data['date_entered']."<br>";
print '</td>';
if ($t == 5) {
print '</tr>';
$t=0;
}
}
print '</table>';
print '<p align="center">';
// next we need to do the links to other results
if($offset >= $limit){
$newoffset=$offset-$limit;
print "<a href=\"$PHP_SELF?catagory=$catagory&offset=$newoffset\">PREV</a> ";
}
// calculate number of pages needing links
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
for ($i=1;$i<=$pages;$i++) { // loop thru
$newoffset=$limit*($i-1);
if ($newoffset != 0){
print "<a href=\"$PHP_SELF?catagory=$catagory&offset=$newoffset\">$i</a> \n";
}
}
// check to see if last page
if($numrows-$offset > $limit){
$newoffset=$offset+$limit;
print "<a href=\"$PHP_SELF?catagory=$catagory&offset=$newoffset\">NEXT</a>\n";
}
print '</p>';
?>