Solved

search script with next/previous button

Posted on 1998-07-05
6
181 Views
Last Modified: 2010-03-05
Hi,

i'm trying to make a search script that searches a database and displays the results but only 10 at a time. If the search returns 200 results I want it to display 10 and then have a next/previous button so that you can view entries before and after...

Is there some code availabel for this? Suppose All my results are in an array called @results could someone please make some code that does the above....

my guess is that it would need to figure out  the total amount of results, figure out which results are being viewed so that it can determine what the next ones should be.
obviously if you are on the first page you will not need a previous button and if you are on the last page you will not need a next button....

Any help would be very much appreciiated i have been trying for ages to work it out.
0
Comment
Question by:intaman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 6

Expert Comment

by:alamo
ID: 1208280
Is your query the type of query that if you run it again when the user presses "Next", you will get the exact same results in the exact same order?

If this is true, the script isn't very tricky at all. If however you can only run the query once then it's more work since you need to save the original results and read them back later. And you need to "clean up" saved copies of old queries.

Which is it?
0
 

Author Comment

by:intaman
ID: 1208281
Hi,

Yes it is the type of script that will return the same results each time....
But i'm still finding it an impossible task :o(

Thanks

0
 
LVL 5

Expert Comment

by:b2pi
ID: 1208282
Is this on a local machine, or is this a cgi script that you want?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:intaman
ID: 1208283
Well both really... I want a cgi script (at least the general code to give me an idea that I could modify myself) to use on a local machine....


0
 
LVL 5

Accepted Solution

by:
b2pi earned 340 total points
ID: 1208284
OK... Here's a rough outline (it's easier to do without the cgi, though) :

Rather than considering a page of displayed records, consider instead a page of records beginning with a particular index.  If the index is not present, consider it to be 0.

Then, you'll have a next button, which simply increments the index by, say 10, and a previous button, which decrements the index by 10.

Each time a post request is made, you'll perform the search , skip the number of records specified by the index, and finally display the appropriate records.

By the way, if this were simply a local process, on the first search, you'd select only the keys for all of the records into an array, and then, using the key, select the data for the first 10 records, using the appropriate keys.  On subsequent searches, you'd already know the keys for the relevant data, and you wouldn't need to re-search the entire data set.
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1208285
Did you get anywhere with this?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

707 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