#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    56
    Rep Power
    3

    Paging through search results - Next/Previous


    Hi,

    I am using a pagination class developed by someone else here . It works okay, except that when I run a query by providing search criteria in text boxes the next and previous does not display the same results from the initial search according to the criteria. It returns all records in database.

    What could be the fix for this problem?


    Part of my query:
    PHP Code:
    <?php

        $sql 
    "SELECT * FROM ".$SETTINGS["data_table"]." WHERE c_id>0".$search_string.$search_ref.$search_cat_id.$search_cmaterial.$search_ctechnic.$search_cartist.$search_cperiod.$search_csource.$search_status;
    $sql_result mysql_query ($sql$connection ) or die ('request "Could not execute SQL query" '.$sql);
    //    pagination code
        
    $PAGING=new PAGING($sql);
        
    //    There are two optional parameters as well:
    //    $records = 16 //Number of records to be displayed per page
    //    $pages = Number of pages to be displayed in the paging
        
    $sql=$PAGING->sql;

    if (
    mysql_num_rows($sql_result)>0) {

    //    The following line gives us an SQL statement with appropriate limits applied
        
    $sql_result=mysql_query($sql) or die($sql." - ".mysql_error());
        
        while (
    $row mysql_fetch_assoc($sql_result)) {
        
    $c_id=$row['c_id'];
    ?>

      .......HTML RESULT TABLE .........

    PAGING:

    <?=$PAGING->show_paging("gallery_sec.php")?>
    Last edited by josephbupe; April 4th, 2013 at 04:17 AM. Reason: correction made
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,027
    Rep Power
    377
    in the query you need to add order by so the query returns results in the same order all the time
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    194
    Rep Power
    77
    read my post here about pagination http://forums.devshed.com/php-development-5/problem-with-pagination-941778.html
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    56
    Rep Power
    3
    I will try that.

    Thanx.

    Joseph
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    9
    Rep Power
    0
    you can use $_php_self and $_Get['page'] to get the values of page then increment it and echo the link.

IMN logo majestic logo threadwatch logo seochat tools logo