Hướng dẫn php update url parameter

I've implemented pagination system for my website in php, only problem with that is following:
suppose my url at which pagination present is,www.abc.com/search.php?mode=study&query=a,currently its showing 20 results per page,when I use pagination to navigate across results, the url changes to www.abc.com/search.php?mode=study&query=a&page=2,www.abc.com/search.php?mode=study&query=a&page=2&page=3 and www.abc.com/search.php?mode=study&query=a&page=2&page=3&page=4,so the problem which I'm facing is when I navigate across results,every time page variable got appended to the url,which is really annoying.
My code for pagination is.

 1)
{  
    $setPaginate .= "
    "; $setPaginate .= "
  • Page $page of $setLastpage
  • "; if ($setLastpage < 7 + ($adjacents * 2)) { for ($counter = 1; $counter <= $setLastpage; $counter++) { if ($counter == $page) $setPaginate.= "
  • $counter
  • "; elseif (isset($_GET['page'])) { unset($_GET['page']); $page_url = http_build_query($_GET); echo $page_url; $setPaginate.= "
  • $counter
  • "; } else $setPaginate.= "
  • $counter
  • "; } } elseif($setLastpage > 5 + ($adjacents * 2)) { if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $setPaginate.= "
  • $counter
  • "; else $setPaginate.= "
  • $counter
  • "; } $setPaginate.= "
  • ...
  • "; $setPaginate.= "
  • $lpm1
  • "; $setPaginate.= "
  • $setLastpage
  • "; } elseif($setLastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $setPaginate.= "
  • 1
  • "; $setPaginate.= "
  • 2
  • "; $setPaginate.= "
  • ...
  • "; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $setPaginate.= "
  • $counter
  • "; else $setPaginate.= "
  • $counter
  • "; } $setPaginate.= "
  • ..
  • "; $setPaginate.= "
  • $lpm1
  • "; $setPaginate.= "
  • $setLastpage
  • "; } else { $setPaginate.= "
  • 1
  • "; $setPaginate.= "
  • 2
  • "; $setPaginate.= "
  • ..
  • "; for ($counter = $setLastpage - (2 + ($adjacents * 2)); $counter <= $setLastpage; $counter++) { if ($counter == $page) $setPaginate.= "
  • $counter
  • "; else $setPaginate.= "
  • $counter
  • "; } } } if ($page < $counter - 1){ $setPaginate.= "
  • Next
  • "; $setPaginate.= "
  • Last
  • "; }else{ $setPaginate.= "
  • Next
  • "; $setPaginate.= "
  • Last
  • "; } $setPaginate.= "
\n"; } return $setPaginate; }

I know problem is with $page_url variable, need help with this little problem