Alright, Didn't get any good responds yesterday so I try again, my thread kinda died.. So the problem is now that I have to limit the data to a max of 25 per page, which is simple by itself, but also what I have to do is to keep it categorized, and I just can't seem to get through with it, can someone enlighten me please? Here is some example code I've tried to fix, but it keeps messing up! The loops gets screwed up.. Here's what I want to get Category 1 - Comment 1 - Comment 2 Category 2 - Comment 1 - Comment 2 Note: This is only testing/example code of what I'm meaning Code: [code] <b> <? echo "<table border=1>"; if(!isset($_GET['page'])){ $numPage = 1; } else{ $numPage = $_GET['page']; } $rowsPerPage = 2; $offset = ($numPage - 1) * $rowsPerPage; $testy = mysql_fetch_array(mysql_query("SELECT category FROM myfriends limit $offset, 1")); $test = mysql_query("SELECT * FROM myfriends limit $offset, $rowsPerPage"); $category=$testy[category]; while(($category < 5) && ($t = mysql_fetch_array($test))){ if($category==1) $cat_text = "Friends"; if($category==2) $cat_text = "Family"; if($category==3) $cat_text = "School"; if($category==4) $cat_text = "The Rest"; echo "<tr><td>$cat_text</td></tr>"; $test3 = mysql_query("SELECT * FROM myfriends where category='$category' limit $offset, $rowsPerPage") or die(mysql_error()); while($e = mysql_fetch_array($test3)){ echo "<tr><td>$e[comment]</td></tr>"; } $category = $category+1; } echo "</table>"; $topage = $numPage +1; echo "<a href=test.php?page=$topage>></a>"; ?> </b> [/code]