When you combine a search form with pagination, you need to embed the search parameters in the paging links.
<?php
if($sqlResult > 1 && $pg<= $sqlResult){
$query = $_GET;
for($i=1; $i<=$sqlResult; $i++){
$query['pg'] = $i;
echo "<a href='?" . http_build_query($query) ."'>$i</a> ";
}
}
?>
The above code takes everything in your current query string and adds in the applicable pg
attribute when building the pagination links.
-- edit --
Combining a POST search form with pagination gets a little weird. There are a couple things you can do:
Use javascript to populate a hidden "page" field in the form when you click one of the pagination links, and resubmit the form, e.g.:
$('.pagination-link').on('click', function() {
$('#page').val($(this).html()); //where you have a hidden field #page
$('$searchform').submit();
});
OR
Change the form method to GET, and use the example I posted above