Hi guys

i have been trying to figure out how i can achieve this but its not quiet working

i have a for loop oping from 21 to 1 for rankings now my pagination system is not limited it 2 per page so this is my code.

PHP Code:
for($i=21$i>= 1$i--)
                    {
                        
//
                        
$num $_GET['num'];//Get the numeration of the page
                        
if(empty($num))
                        {
//if the numeration is empty
                        
$num 1;//the numeration is 1
                        
};            
                        
$limit 2;
                        
$start = ($num-1)*$limit;
                        
$start round($start,0);//rounds the result

                        
include("dbconnect.php");
                        
$query="SELECT * FROM members WHERE disable='1' AND rank='$i' LIMIT $start,$limit";
                        echo 
$query;
                        
$rs=mysqli_query($con,$query);
                        if(!
$rs)
                        {
                        echo 
"Error:".mysqli_error($con);
                        }
                        else
                        {
                            
//
                            
$count=$rs->num_rows;
                            if(
$count>0)
                            {
                                
                                while(
$data=$rs->fetch_assoc())
                                {
                                  
//
                                  
$rank=$data['rank'];
                                  
$aim=$data['aim'];
                                  
$LastedLogin=$data['LastedLogin'];
                                  echo 
"<font color=".$data['fontcolor']." size=".$data['fontsize']."><tr>
                                  <td></font>"
;
                                  
get_rank_by_id($rank);
                                  echo 
"</td></font>";
                                  echo 
"<td><a href=\"index.php?cmd=profile&mid=".$data['mid']."\">".$data['username']."</font></a></font>";
                                        echo 
"<td><a href=aim:goim?screenname=".$data['aim']."&message=Hi.+Are+you+there".$data['aim']."</a></td><td></font>";
                                        
calcDSL($username,$LastedLogin);
                                        echo 
"&nbsp;Days ago</td></font>";
                                        echo 
"<td></font>";
                                        if(
$data['gamesplayed']="")
                                        {
                                            echo 
"Has Not Been Set</font>";
                                        }
                                        else
                                        {
                                            echo 
"".$data['gamesplayed']."</font>";
                                        }
                                        echo 
"</td>
                                        <td></font>"
;
                                        if(
$data['onlinestatus']=="1")
                                        {
                                            echo 
"<img src=\"images/on.gif\" width=\"12\" height=\"12\" /></font>";
                                        }
                                        else if(
$data['onlinestatus']=="0")
                                        {
                                            echo 
"<img src=\"images/off.gif\" width=\"12\" height=\"12\" /></font>";
                                        }
                                        echo 
"</td>
                                        <td></font>"

                                        if(
$data['web']=="1")
                                        {
                                            echo 
"Yes</font>";
                                        }
                                        else
                                        {
                                           echo 
"No</font>";
                                        }
                                        echo 
"</td>
                                        </tr></font>"
;//Echoes the content
                                  //
                                
}
                            }
                        }
                        
//
                    
}
                                
$totalpages mysqli_num_rows(mysqli_query($con,"SELECT * FROM members WHERE disable='1' AND rank=$i")); 
                                
$totalpages $totalpages $limit;
                                
$totalpages round($totalpages,0);
                                
$c 0;//The variable c is 0
                                
echo "<br>";//make a <br> to separate the results from the [1][2]...
                                
while($c<$totalpages)
                                {
//while c is < than the total pages
                                    
$page $c 1;//sets the variable $page as 0 + 1 = 1
                                    
if($_GET['num']==$page)            
                                    {
//Gets the number of the page and if its the same that the page
                                        
echo "[$page]";//its only echoes the page, not the url to this page
                                    
}
                                    else
                                    {
//else
                                      
echo "<a href=index.php?cmd=Members&num=$page>[$page] </a>";//it echoes the url to the page
                                    
}
                                    
$c $c+1;
                                }
                                echo 
"<br>".$totalpages." Pages in total.";//echoes the total pages 
There is no errors vbut i am wanting it to do the same thing for displaying the number of pages displays more than one pages i dunno why but this is happing?

Thanks,William