PDA

View Full Version : next / previous by using LIMIT o.k?


[o_O]
12-30-2002, 09:33 AM
I am thinking that it would be nice to add some 'next/previous' functionality to my results page.

The examples of this I have looked at seem quite complicated though so I thought I could do it the same way as i used with PHP which is by using the SQL 'LIMIT'

Is this method ok? or a bad idea :confused:

Bullschmidt
12-30-2002, 03:42 PM
Never heard of LIMIT but I mostly work with Access databases.

But if it actually works, it sounds like a great idea!

[o_O]
12-30-2002, 09:55 PM
SELECT whatever FROM someTable LIMT offset, perPage

offset = row number you want to start from
perPage = obviously how many to display per page


There are two things that make me think this could be a bad idea for a site which may have medium to heavy traffic and one you want to go fast. These are

1. you need to run an extra query (just to see how many rows are actually returned -otherwise how will the asp now to put 'next or not')

2. the query shown above will execute each time (results 1, results 2 etc)

[o_O]
12-30-2002, 10:31 PM
nope :( I was kidding myself, when i used this way with php the query and code qas much more simple, after playing with this it is just not an effective solution, it uses too much code and too many big queries especially since the SQL on the results page is dynamic it makes some things like using the 'COUNT' function seemingly impossible.

whammy
12-31-2002, 12:21 AM
Look up "database paging ASP" on google, you will find some good links/tutorials. :)

[o_O]
12-31-2002, 02:59 AM
Thanks, took your advice and it's now working :) not as bad as I thought.

Reference to these two: 1 (http://www.asp101.com/samples/db_paging.asp) 2 (http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeId=6444)