Variables not Passing to Page 2.....

Posted on 2007-10-09
Last Modified: 2013-12-13
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 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());


Question by:webseth
    LVL 50

    Accepted Solution

    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.?
    LVL 1

    Author Comment

    there is a form on the previous page that passes the variables
    LVL 1

    Author Comment

    Figured it out. Accidentally put a session_start() and Destroy in the header. Got it fixed!

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now