[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 210
  • Last Modified:

Variables not Passing to Page 2.....

I have a search form that runs fine. On the second page, I pull all of the records with no problem. I also have a pagination script on this page. When I click on page 2, or 3 or whatever, the variables do not continue to transfer. I've been using sessions....am I missing something here? Below is the part of the Script at the top I am having trouble with:

$_SESSION['ar'] = $ar;
$_SESSION['bd'] = $bd;
$_SESSION['ba'] = $ba;
$_SESSION['pmin'] = $pmin;
$_SESSION['pmax'] = $pmax;
$_SESSION['page'] = $page;
include ('header.php');
include ('dbconnect.php');
   class Pager  
       function getPagerData($numHits, $limit, $page)  
           $numHits  = (int) $numHits;  
           $limit    = max((int) $limit, 1);  
           $page     = (int) $page;  
           $numPages = ceil($numHits / $limit);  

           $page = max($page, 1);  
           $page = min($page, $numPages);  

           $offset = ($page - 1) * $limit;  

           $ret = new stdClass;  

           $ret->offset   = $offset;  
           $ret->limit    = $limit;  
           $ret->numPages = $numPages;  
           $ret->page     = $page;  

           return $ret;  

// get the pager input values
    $limit = 15;  
    $result = mysql_query("select count(*) from DailyData_CATisRES WHERE (AREA = '$ar') AND (BEDROOMS >= '$bd') AND (BATHS >= '$ba') AND (CURRENT_PRICE >= $pmin) AND (CURRENT_PRICE <= $pmax)");  
    $total = mysql_result($result, 0, 0);  
    // work out the pager values
    $pager  = Pager::getPagerData($total, $limit, $page);  
    $offset = $pager->offset;  
    $limit  = $pager->limit;  
    $page   = $pager->page;  

    // use pager values to fetch data
    $query = "SELECT * FROM DailyData_CATisRES WHERE (AREA = '$ar') AND (BEDROOMS >= '$bd') AND (BATHS >= '$ba') AND (CURRENT_PRICE >= $pmin) AND (CURRENT_PRICE <= $pmax) ORDER BY 'CURRENT_PRICE' DESC LIMIT $offset, $limit";  
    $result = mysql_query($query) or die(mysql_error());  

    // use $result here to output page content
$row = $result;
$rowcount = mysql_num_rows($row) or die(mysql_error());


  • 2
1 Solution
Steve BinkCommented:
Is there code that comes before this?  You are setting the session variables at the beginning, but I don't see where you are setting the variables you reference.  Where do you get the values of $ar, $bd, $ba, etc.?
websethAuthor Commented:
there is a form on the previous page that passes the variables
websethAuthor Commented:
Figured it out. Accidentally put a session_start() and Destroy in the header. Got it fixed!

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now