not to offend you Mayus as you have tried to help me , but it still dont work. heres the entire original code
if (!($limit)){
$limit = 20;}
if (!($page)){
$page = 0;}
$numresults = mysql_query($sql4, $connection) or die ("Could nt execute query");
$numrows = mysql_num_rows($sql_result4);
$pages = intval($numrows/$limit);
if ($numrows%$limit){
$pages++;}
$current = ($page/$limit) + 1;
if (($pages < 1 ) || ($pages == 0)){
$total = 1;}
else {
$total = $pages;}
$first = $page + 1;
if (!((($page + $limit)/ $limit) >= $pages) && $pages != 1){
$last = $page + $limit;}
else {
$last = $numrows;}
for ($i=1; $i <= $pages; $i++){
$ppage = $limit*($i - 1);
if ($ppage == $page){
echo " $i ";
}
else{
echo "<a href=\"$PHP_SELF?query=$query&page=$ppage&limit=$limit\"> $i </a>";}
}