动态PHP分页

My pagination code in php only lists pages without control, if i have 100 pages it will list the 100 without shortening say like 1 2 3 ... 98 99 100, but it will list it from 1 to 100 without abbreviation, this is the pagination code i have:

<?php
  $result = $myApp->dbTransaction("SELECT * FROM cause_lists;");

$getNum = mysql_num_rows($result);

$pg = $getNum/10;
$rem = ($getNum%10)/10;
if ($rem > 0) {
$pg -=$rem;
$pg +=1;
}

if ($pg == 2 || $pg > 2){
    $page_num = $pg;

} 
if (!empty($page_num)){
    if ($range_filter === 0){$arrow_class_1 = "arrow unavailable";
    $arrow_link_1 = "#";
    } 

    else {$arrow_class_1 = "arrow";
    $r = $range_filter + 0;
    $arrow_link_1 ="cl_admin.php?range=$r";
    }

    if ($range_filter != (($pg * 10) - 10)) {$arrow_class_2 = "arrow"; $arrow_link_2 ="#";
    $r = $range_filter + 20;
    $arrow_link_2 ="cl_admin.php?range=$r";
    }
    else {$arrow_class_2 = "arrow unavailable";
    $arrow_link_2 ="#";
    }
    echo " <ul class=\"pagination\"><li class=\"$arrow_class_1\"><a href=\"$arrow_link_1\">&laquo;</a></li>";
    for($i=1; $i<=$page_num; $i++){
        $rge = $i * 10;
        if(($range_filter+10) === $rge){$page_class = "current";} else {$page_class = "";}
        echo "<li class='$page_class'><a href=\"cl_admin.php?range=$rge\">$i</a></li>";
    }
    echo "<li class=\"$arrow_class_2\"><a href=\"$arrow_link_2\">&raquo;</a></li></ul>";
}

  ?>

You may try my pagination library. http://www.okvee.net/articles/%E0%B9%81%E0%B8%9A%E0%B9%88%E0%B8%87%E0%B8%AB%E0%B8%99%E0%B9%89%E0%B8%B2%E0%B9%81%E0%B8%AA%E0%B8%94%E0%B8%87%E0%B8%9C%E0%B8%A5%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-pagination-class

Sorry, the document is in Thai language but i'm sure you can easily understand.

set $config['num_links'] to show how many pages visible.