Looking for a little bit of advice on recordset paging within a PHP page.

I've been working with PHP for about a year, and have learnt a massive amount, but would still class myself as a newby.

I'm making a PHP with an onscreen keyboard. Using this keyboard you can type into a search box to search through a MySQL database. This is working perfectly well.

I have adapted the search from an earlier site that a friend helped me with, and my understanding of the code is that inside the <div class="err"> </div> is displayed either:

1 - the full list of results before anything is typed into the search box

2 - the filtered list of results dynamically as letters are typed

3 - the full list of results if all search letters are deleted

The first of these comes from within the page, the second two from a separate file "search.php"

With me so far.....

This is all fine too... MY problem is when trying to use recordset paging to scroll through the results. My untrained logic says I need to set this up three times, one for each method above. So I set up recordset paging for the first option (when no search is performed) and this is fine. Lovely in fact.

My problem is trying to use paging when a search has been made (or deleted) so option 2 and 3 above. When trying to page to the 'next' set of results here I'm taken to the actual search.php page, rather than having it display within the div tags.

My question is this... Am I barking up the wrong tree trying to get this to work? I keep hearing about AJAX which I have no experience of AT ALL, and while I'm aware this may be the way forward, Id love to try and work out a fix without for now. I'm guessing I need to do something with the querystrings within search.php but as to what.....

That said, does anyone know any good AJAX tutorials. I only need to work with PHP/MySQL and it all seems to be XML which again is something of the dark arts to me.

Any words of wisdom would be appreciated. I can pay in gin!

HTML Code:
<div class="search_results" id="search-results" style="display: inherit">
    <div id="search_results">
      <div class="err">  
        <div class="results-header">
          Results (<?php echo mysql_num_rows($results_empty)?> of <?php echo $totalRows_results_empty?>)
        </div>
        
         <ul style="column-count: 2; column-gap: 0; -moz-column-count: 2; -moz-column-gap: 0; -webkit-column-count: 2; -webkit-column-gap: 0; width: 1000px;position: relative; left: -40px;">
		<?php do { ?> 
           <li style="display: inline-block; width: 500px; height: 40px; text-align: left; font-size: 18px;	line-height: 20px; color: white;" onClick="closed('<?php echo $row_results_empty['key']; ?>')">
           <div id="searchclick" >
             <span style="font-family: 'fs_elliotbold';"><?php echo $row_results_empty['surname']; ?>,</span> <?php echo $row_results_empty['firstname']; ?>   <?php echo $row_results_empty['rank']; ?>
           </div>
          </li>
          <?php } while ($row_results_empty = mysql_fetch_assoc($results_empty)); ?>
        </ul>
        
        <div class="record-paging-next">
		<?php if ($pageNum_results_empty < $totalPages_results_empty) { // Show if not last page ?>
        <a href="<?php printf("%s?pageNum_results_empty=%d%s&amp;search=yes", $currentPage, min($totalPages_results_empty, $pageNum_results_empty + 1), $queryString_results_empty); ?>">
        <img src="images/arrow-next.png" width="58" height="97" alt=""/>
        </a>
        <?php }?>
        </div>
        
        <div class="record-paging-previous">
        <?php if ($pageNum_results_empty > 0) { // Show if not first page ?>
        <a href="<?php printf("%s?pageNum_results_empty=%d%s&amp;search=yes", $currentPage, max(0, $pageNum_results_empty - 1), $queryString_results_empty); ?>">
        <img src="images/arrow-previous.png" width="58" height="97" alt=""/> 
        <?php }?>
        </a>
        </div>

      </div>
    </div>
  </div>
The javascript to drive the search on this page is

HTML Code:
<!--Javascript to function keyboard-->
<script>
function keypress(letter) {
var TheTextBox = document.getElementById("search");
    TheTextBox.value = TheTextBox.value + letter;
        // Get the search value
        var search_value = $("input[name='search_term']").val();

        // This time we're going to grab data from a file to display
        var filename = "functions/search.php";

        // Send these values
        var posting = $.post(filename, { search_term: search_value });

        // Display this value in our results container
        posting.done(function (data) {
          $("#search_results").empty().append(data);
        });

$('#' + letter).hide();
$('#' + letter + 'UP').show();
		setTimeout(function(){
    // Slow can be any number of ms
    $('#' + letter).show();
    }, 300); 
		setTimeout(function(){
    // Slow can be any number of ms
    $('#' + letter + 'UP').hide();
    }, 300); 

}
</script>
And my search.php file is

HTML Code:
<?php if (! $_POST["search_term"]) { ?>
  <div class="err">
    <div class="results-header">
    Results (<?php echo mysql_num_rows($Recordset1)?> of <?php echo $totalRows_Recordset1?>)
    </div>
    <ul style="column-count: 2; column-gap: 0; -moz-column-count: 2; -moz-column-gap: 0; -webkit-column-count: 2; -webkit-column-gap: 0; width: 1000px;position: relative; left: -40px;">
      <?php do { ?>
      <li onClick="closed('11')" style="display: inline-block; width: 500px; height: 40px; text-align: left; font-size: 18px; line-height: 20px; color: white;">
	  <span style="font-family: 'fs_elliotbold';"><?php echo $row_Recordset1['surname']; ?>,</span> <?php echo $row_Recordset1['firstname']; ?>   <?php echo $row_Recordset1['rank']; ?>
      </li>
      <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
    </ul>
    
      <div class="record-paging-next">
		<?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
        <a href="<?php printf("%s?pageNum_Recordset1=%d%s&amp;search=yes", $currentPage, min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>">
        <img src="images/arrow-next.png" width="58" height="97" alt=""/>
        </a>
        <?php }?>
    </div>
        
        <div class="record-paging-previous">
        <?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
        <a href="<?php printf("%s?pageNum_Recordset1=%d%s&amp;search=yes", $currentPage, max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>">
        <img src="images/arrow-previous.png" width="58" height="97" alt=""/> 
        <?php }?>
        </a>
        </div>
</div>

<?php } else { ?>
    <div class="results-header">
    Results (<?php echo mysql_num_rows($results)?> of <?php echo $totalRows_results?>)
    </div>
 <ul style="column-count: 2; column-gap: 0; -moz-column-count: 2; -moz-column-gap: 0; -webkit-column-count: 2; -webkit-column-gap: 0; width: 1000px;position: relative; left: -40px;">
  <?php do { ?>
    <li onClick="closed('<?php echo $row_results['key']; ?>')" style="display: inline-block; width: 500px; height: 40px; text-align: left; font-size: 18px; line-height: 20px; color: white;">
	<span style="font-family: 'fs_elliotbold';"><?php echo $row_results['surname']; ?>,</span> <?php echo $row_results['firstname']; ?>   <?php echo $row_results['rank']; ?>
    </li>
    <?php } while ($row_results = mysql_fetch_assoc($results)); ?>
</ul>

      <div class="record-paging-next">
		<?php if ($pageNum_results < $totalPages_results) { // Show if not last page ?>
        <a href="<?php printf("%s?pageNum_results=%d%s&amp;search=yes", $currentPage, min($totalPages_results, $pageNum_results + 1), $queryString_results); ?>">
        <img src="images/arrow-next.png" width="58" height="97" alt=""/>
        </a>
        <?php }?>
</div>
        
<div class="record-paging-previous">
        <?php if ($pageNum_results > 0) { // Show if not first page ?>
        <a href="<?php printf("%s?pageNum_results=%d%s&amp;search=yes", $currentPage, max(0, $pageNum_results - 1), $queryString_results); ?>">
        <img src="images/arrow-previous.png" width="58" height="97" alt=""/> 
        <?php }?>
        </a>
        </div>


<?php } ?>

<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>">previous 1</a> 
<a href="<?php printf("%s?pageNum_results=%d%s", $currentPage, max(0, $pageNum_results - 1), $queryString_results); ?>">prevoius 2</a> 
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>">next 1</a> 
<a href="<?php printf("%s?pageNum_results=%d%s", $currentPage, min($totalPages_results, $pageNum_results + 1), $queryString_results); ?>">next 2</a>
</body>
</html>
<?php
mysql_free_result($results);

mysql_free_result($Recordset1);
?>