Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Nov 2011
    Posts
    77
    Thanks
    4
    Thanked 0 Times in 0 Posts

    problem with pagination

    after submit a search the url with the results would be www.domain.com/link.php="the searched options"&submit=submit

    and my pagination link code is something like that:
    $page_numerotation .= ($x == $page) ? '<strong>' . $x . '</strong> ' : '<a href="?page=' .$x. '"> ' . $x . '</a> ';

    and it looks something like that:
    www.domain.com/link.php?page=2 (or 3, or 4, ...)
    and obviously dosn't works...

    so... how can I fix the problem?

    ty

  • #2
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Really depends on how your pagination is actually working, but I'm guessing changing the anchor's href to www.domain.com/link.php="the searched options"&submit=submit&page=x.
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • #3
    New Coder
    Join Date
    Nov 2011
    Posts
    77
    Thanks
    4
    Thanked 0 Times in 0 Posts
    my cod is starting with this line

    PHP Code:
    if($_GET){ 

  • #4
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Quote Originally Posted by _user View Post
    my cod is starting with this line

    PHP Code:
    if($_GET){ 
    Doesn't tell me anything - any .php page with a query string will use $_GET somewhere.

    Try what I said above.
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • #5
    New Coder
    Join Date
    Nov 2011
    Posts
    77
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I have any $_POST LINE

    with that line starts the code...

    than query line

    and than

    $per_page = 10;
    $pages_query = mysql_query ("SELECT COUNT('ID') FROM table");
    $pages = ceil(mysql_result($pages_query, 0) / $per_page);

    $page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1;
    $start = ($page - 1) * $per_page;


    $results_list = mysql_query($query_list) or die(mysql_error());
    $results = mysql_query($query) or die(mysql_error());
    $count = mysql_num_rows($results_list);
    if($count > 1){
    $search_output .="<hr />$count results <br />";
    while($row = mysql_fetch_array($results)){

    blablabla

    }}
    if($pages >= 1 && $page <= $pages){
    for ($x=1; $x<=$pages; $x++){
    $page_numerotation .= ($x == $page) ? '<strong>' . $x . '</strong> ' : '<a href="?page=' .$x. '"> ' . $x . '</a> ';
    }

  • #6
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    Yup, my first reply will work.

    In the future, use [PHP] tags to wrap your PHP code.
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

  • #7
    New Coder
    Join Date
    Nov 2011
    Posts
    77
    Thanks
    4
    Thanked 0 Times in 0 Posts
    ok... but change what? where?
    I don't use no $_POST

    I`v changed the firs line with that... and gives no results on searching....
    Last edited by _user; 01-23-2012 at 09:07 AM.

  • #8
    New Coder
    Join Date
    Nov 2011
    Posts
    77
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I rerwite the cod and now works.
    I don't know wich was the problem, but... now works fine.
    Thank you for your time...

  • #9
    Senior Coder
    Join Date
    Jul 2011
    Posts
    1,226
    Thanks
    3
    Thanked 171 Times in 171 Posts
    All you needed to do was change the <a> tag's href for the next page to include the search string as well, just like I said in my first reply.
    Useful function to retrieve difference in times
    The best PHP resource
    A good PHP FAQ
    PLEASE remember to wrap your code in [PHP] tags.
    PHP Code:
    // Replace this
    if(isset($_POST['submitButton']))
    // With this
    if(!empty($_POST))
    // Then check for values/forms. Some IE versions don't send the submit button 
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •