OK, I have a question: If "1005(next)" is deleted, why: 1) Is it still in the file system, or 2) Not flagged as deleted in the database?
Use SQL on each page hit, but do a UNION join. The example below is from a database called "quotations", and gives list of current (7) id, previous and next: SELECT quotation_id FROM quotation WHERE quotation_id = 7 AND date_deleted IS NULL UNION SELECT top 1 quotation_id FROM quotation WHERE quotation_id > 7 AND date_deleted IS NULL UNION SELECT MAX(quotation_id) as quotation_id FROM quotation where quotation_id < 7 AND date_deleted IS NULL ORDER BY quotation_id RESULTS: quotation_id ------------ 4 7 8 Unions are not terribly efficient, but they do the job cleanly and -probably - better than pulling back up to 3000 results. That make sense?? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm?link=i:4:138019 Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Get the mailserver that powers this list at http://www.coolfusion.com