Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - apply loop to one recordset element only
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

apply loop to one recordset element only

 Post Reply Post Reply
Author
the boss View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 January 2003
Location: Saudi Arabia
Status: Offline
Points: 1727
Post Options Post Options   Thanks (0) Thanks(0)   Quote the boss Quote  Post ReplyReply Direct Link To This Post Topic: apply loop to one recordset element only
    Posted: 12 July 2003 at 7:14pm


i've a page which displays results from a recordset..

sample code below

  <td nowrap>CC</td>
    <td nowrap><%=rs("CC")%></td>
  </tr>
  <tr>
    <td nowrap>FF</td>
    <td nowrap><%=rs("FF")%></td>
  </tr>
  <tr>

how can i apply loops to <%=rs("CC")%> only..im get an EOF or BOF error when i apply loop to only on elemnt in recordset..what is a work around to this...



Edited by the boss

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 12 July 2003 at 7:27pm
Set the record to an array
arrayName = RecordSetName.GetRows
and you can loop without worrying about EOF or BOF.
The array is a 2 dimensional array. The first dimension is the numerical position of the field starting with 0. The secod dimension is the row number from the recordset (starting with 0).

If you used the following SQL statement:
select field1, field2 from table
and placed it into the array, arrArray then the first to return field1 from the first row would be <%=arrArray(0,0)%>
field2 from the first row is: <%=arrArray(1,0)%>
field2 from the 30th row is: <%=arrArray(0,29)%>

To loop through the array use:
<%
for i = 0 to Ubound(arrArray,2)
' Write the first field for each row i
   Response.write arrArray(0,i) &"<br>"
next
%>

Back to Top
 Post Reply Post Reply

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.