devxlogo

Limiting Search Results

Limiting Search Results

Question:
When my clients enter searching criteria, I want to limit the number of results. For example, if the number of results is over 100, I want the user to have to go back and try the search again. How can I do this?

Answer:
An easy way is to do a SELECT COUNT(*) FROM … WHERE … so that you get the number of records instead of the records. If you get too many, display that fact to the user. If not, do the other query. An alternative is to do the whole query, but only let the user see 100 results?keep a counter going while you’re dumping the records out.

devx-admin

Share the Post: