Paging Results not printing on other pages

They have: 1 posts

Joined: Apr 2005

Below is my script to query my db to search for models that part is fine the second part os a pagination script to set a limit on results which I have set to $limit=4; right now. So if the db is quered and 8 results are returned there will be 2 pages of results. Well everything is ok it set up 2 pages with hyper links printed out the first 4 results on page 1 are fine.

PROBLEM the results on any other page than 1 do not print out. Anyone have a fix for this. HELP!

Thanks in advance for any help!
Phil

<?php
         session_start
();


require(
"login.php");

  if(!
array_key_exists('generate', $_SESSION))
   
$_SESSION['generate'] = rand(1,100);

 
$generate = $_SESSION['generate'];
     
$limit = 4;
?>

<?php
$id
= str_replace(",", "','", $_POST['id']);
               
$name_last = str_replace(",", "','", $_POST['name_last']);
             
$name_first = str_replace(",", "','", $_POST['name_first']);
            
$country = str_replace(",", "','", $_POST['country']);
                
$sex = str_replace(",", "','", $_POST['sex']);




if(isset(
$_POST["Submit"]) && !empty($_POST["Submit"])){
   
$country_block = $sql = "SELECT * FROM models WHERE country IN ('$country') AND sex IN ('$sex') ORDER BY RAND($generate)";

   
$result = mysql_query($sql,$getconx) or die (mysql_error());
   
$total = mysql_num_rows($result);
     if(
$total > $limit)
                       {
   
$pages = floor(($total / $limit));

    if((
$total % $limit) > 0) { $pages++; } #If this is true, then we need an extra page for the values that are not even
   
}
    if(
$total == 0) {
    echo
"<b>No Models Where Found With Those Parameters.... Please Try Again!</b><br>";
            } else {
            echo
"$total Models Found<br>";

   
$color ="#FFFFFF";

   
$records = $_GET['r'];
    if(
$records == 0) $records = $limit;
    if(
$_GET['f'] == 0) $row = 0; else $row = $_GET['f'];
    

    while (
$row < $records){


   
// Echo out the results

   
echo"ID: ".mysql_result($result,$row,'id')." &nbsp; Country: ".mysql_result($result,$row,'country')." &nbsp; &nbsp; Name: ".mysql_result($result,$row,'name_first')." &nbsp; ".mysql_result($result,$row,'name_last')." &nbsp; Sex: ".mysql_result($result,$row,'sex')." <br>";

   
$row++;
    if(
$row == $total)break;
    if(
$color == "#ffffff") $color = "#F0F0F0"; else $color ="#FFFFFF";
        }
    }
}
                            echo
"<table border=0 valign=bottom height=25 align=left width=100% cellpadding=0 cellspacing=0><tr><td valign=bottom>"; #This piece of code makes the pages have link to the sections. Don't change it!
                               
$jrw = $jrr = 0;
                                if(
$total > $limit) echo "&nbsp;Pages: ";
                                for(
$ploop=1;$ploop<=$pages;$ploop++)
                                    {
                                     if(
$ploop != $pages) $spot = " | "; else $spot = "";
                                     if(
$f == $jrw) echo "<font class=pageact>[X]</font>". $spot;
                                     else
                                      echo
"<a href=".$PHP_SELF."?f=".$jrw."&r=".$jrr." class=pagelnk>".$ploop ."</a>". $spot;
                                    
$jrw += $limit;
                                    
$jrr = $jrw + $limit;
                                    }
                               
                            echo
"</td></tr></table>";


   
?>