The solution you implement will depend on your current situation. One decision you must make is whether to use a SELECT statement, or the traditional SET ORDER TO/SEEK combination. Typically, if you are searching on an indexed value, the SEEK command will give you better performance, but obviously SELECT statements are more flexible in terms of the kinds of searches you can perform. Also, if you are querying against an ODBC data source then the SELECT statement method will work better (but you should also look into the caching technique described later).
Nomatter which technique you end up choosing, you will need to save the current page number and search criteria as hidden fields or query string variables. When a user clicks on the Next/Previous button, this information will be passed back to the server. Your script should first access the first record of the search (either by re-issuing the SELECT statement, or the SEEK command) and then SKIP to the correct record:
<%
CurPage= Request.Form("CurPage")
ProductCateg = Request.Form("ProductCateg")
DO CASE
CASE Request.Form("MovePage") = 'Next'
CurPage = CurPage + 1
CASE Request.Form("MovePage") = 'Previous'
CurPage = CurPage - 1
ENDCASE
SELECT FROM product WHERE category = ProductCateg ORDER BY Name
SKIP CurPage
%>
... (insert HTML code to display the current record) ...
<form action="MyScript.fwx" method="POST">
<input type="hidden" name="CurPage" value="<%=CurPage%>">
<input type="hidden" name="ProductCateg" value="<%=ProductCateg%>">
<input type="submit" name="MovePage" value="Next">
<input type="submit" name="MovePage" value="Previous">
</form> %> |
Obviously the above example is missing a lot of code, such as a check for the end of the result set, but you get the idea.
If you go with a SELECT search, then another decision you must make is whether you want to redo your search with every request, or cache the result set, by saving it as a temporary table on the server and passing the file name as a hidden field. The answer to this will depend on how long it takes to perform the search, how often this type of search occurs, the size of the result set, etc..
The ContactMine2 sample application illustrate some of the paging techniques described above.
FoxWeb Support Team
support@foxweb.com
Sent by javier conde on 04/09/2002 11:06:20 AM:
Hi, i have a question, i need implement NEXT/PREVIUS button, but i donīt undertand this, sorry, i am dummy :)
how i can if:
i use a SQL consult and use SCAN/ENDSCAN to display this, work fine, only that if are much record is slow....etc..etc.
thank you |