Jump to content

Paging through results from query based on form variables


daneaffr

Recommended Posts

I'm very new to this and really could use some help. I've got a Web app that has one form that collects data from the user and puts it into a mysql database and has another form that allows the user to select critiera to find records in the database and display them on the page.  All this is working just fine, but now that my database is getting more data in it, I want to add functionality to display 10 records on a page with results page navigation links so the user can move forward and backward in the results set.  This part is not working and I've put in echo statements to figure out what the code is doing.

 

The problem I'm having is that when the selection critiera pulls more than 10 records from the database, the first page of results is correct per the selection criteria entered by the user on the select form.  When the 'next' link is selected to review the second page of results, the query is executed again.  But this time the form variables have been reset and the results now contains the entire contents of the db.  The start record is set to look at the 11th instance of the results set, so the second page starts with the 11th record in the database instead of the 11th record in the original results set.

 

The original select statement is built by determining which criteria is selected using $_POST against each form variable.  How can I retain the form variables or the original select statement  so the second execution of the select statement results in the same results set as the first? The other option that may be better is to retain the original results set and avoid re-executing the select statement altogether.  But I don't know how to do that either.  Any suggestions, code samples or adivice is much appreciated!

Link to comment
Share on other sites

I checked out this tutorial and it is very easy to understand and it works for displaying every record in the db, but it ignores the conditions set in the where clause based on the selection criteria in the form that calls the results page.  I'm so new to this and teaching myself as I go, so I'm befuddled as to why it is ignoring that.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.