...like I said there is a simpler way...
Add these lines tou your sql statement:
if(!$GET['lim']){
$GET['lim']=10;//if there is no limit requested put it to be 10
}
$sql .= " LIMIT ";
$sql .= $GET['lim']-10;
$sql .= ",";
$sql .= $GET['lim'];
The line would be the code for the next page...
echo "<a href=\"page.php?lim=".($_GET['lim']+10)."\">next page>>></a>
Basically, what are you doing here is to put limit on SQL query so it would limit your results comming from the db... Thus you would have a foreach with no limitations on every page because you would have a limited array in question...
You should have mentioned that araay was from the db... I've would have helped you with my first post which would be like this one...
But, hey, hope this solves your problems...