Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - how to select 2 up and 2 down
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

how to select 2 up and 2 down

 Post Reply Post Reply Page  <12
Author
theSCIENTIST View Drop Down
Senior Member
Senior Member


Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
Post Options Post Options   Thanks (0) Thanks(0)   Quote theSCIENTIST Quote  Post ReplyReply Direct Link To This Post Posted: 04 October 2004 at 11:52am
Right, I see now, well, I can't think of any way to retrieve a bunch of records that are around a given record, I can only think at this time to retrieve all records, then sort them out one by one and get your 5 (inc. bill) like that, this is very inneficient method but that's all I can think of right now.

strSQL = "SELECT allFIELDS FROM someTBL"


rsRecSet.Open strSQL, strCon

Dim I, arrID(4), arrName(4), arrCash(4)

Do While Not rsRecSet.EOF
  If int(rsRecSet("ID")) = 29 Then
    rsRecSet.Move - 2
    For I = 0 To 4
      arrID(I) = rsRecSet("ID")
      arrName(I) = rsRecSet("Name")
      arrCash(I) = rsRecSet("Cash")
      rsRecSet.MoveNext
    Next
    Exit Do
  End If
  rsRecSet.MoveNext
Loop


This should do it, note you have to change things to match your data, also note, this was not tested and was just written as I went along with my code logic, but it should work, at least the principle should. Also not sure if ASP supports multi-column arrays (someARR(4, 4, 4)) if so you could use that.

Retrieve your data with this:

For I = 0 To 4

  Response.Write(arrID(I) & " " & arrName(I) & " " & arrCash(I))
Next


The above should return your 5 records.

Let me know how it went.

Edited by theSCIENTIST
Back to Top
asp what that?? View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 08 November 2003
Location: United States
Status: Offline
Points: 140
Post Options Post Options   Thanks (0) Thanks(0)   Quote asp what that?? Quote  Post ReplyReply Direct Link To This Post Posted: 04 October 2004 at 1:54pm
ty...i will try it as soon as i get off work tonite
Back to Top
 Post Reply Post Reply Page  <12

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.