Showing records

1. Junior Member
Join Date
Dec 1969
Posts
13

## Showing records

Hi! <BR><BR>The ultimate challenge for me is to do <BR>a code that prints rs into two different <BR>columns, like this:<BR><BR>There is 8 records in the db, the code sees that ok, 8/2=4, <BR>so 4 rows needs to be written:<BR><BR>name1 name5<BR>name2 name6<BR>name3 name7<BR>name4 name8<BR><BR>And if the rs number is for example 9, the code<BR>prints those records like this:<BR><BR>name1 name6<BR>name2 name7<BR>name3 name8<BR>name4 name9<BR>name5

2. Senior Member
Join Date
Dec 1969
Posts
16,931

## Right...

&#060;%<BR>myArray = objRS.GetRows()<BR><BR>intTotalRecords = UBound(myArray)+1<BR>&#039; There need to be CInt(intTotalRecords/2) rows<BR>Response.Write("&#060;table&#062;")<BR>For i=0 to CInt(intTotalRecords/2)<BR> Response.Write("&#060;tr&#062;&#060;td&#062;" & myArray(i) & "&#060;/td&#062;&#060;td&#062;" & myArray(i+CInt(intTotalRecords/2)) & "&#060;/td&#062;&#060;/tr&#062;")<BR>Next<BR>Response.Write("&#060;/table&#062;")<BR>%&#062;<BR><BR>Try that.<BR><BR>Craig.

3. Senior Member
Join Date
Dec 1969
Posts
433

## RE: Showing records

Why not store the records in an arrray and then place them in table cells using a loop that increments the array position?<BR><BR>count = 1<BR><BR>DO WHILE count &#060; numberofrecords + 1<BR><BR>response.write("&#060;tr&#062;&#060;td&#0 62;arrayname(0,count)&#060;/td&#062;")<BR>response.write("&#060;td&#062;arrayn ame(0,count)&#060;/td&#062;&#060;/tr&#062;")<BR><BR>LOOP<BR><BR>This may well be wrong because I&#039;m not awake yet. Hmm, shouldn&#039;t really be posting.

4. Senior Member
Join Date
Dec 1969
Posts
16,931

## Good point, will

Forgot that the GetRows() array is two-dimensional :)<BR><BR>&#060;% <BR>myArray = objRS.GetRows() <BR><BR>intTotalRecords = UBound(myArray, 2)+1 <BR>&#039; There need to be CInt(intTotalRecords/2) rows <BR>Response.Write("&#060;table&#062;") <BR>For i=0 to CInt(intTotalRecords/2) <BR> Response.Write("&#060;tr&#062;&#060;td&#062;" & myArray(0, i) & "&#060;/td&#062;&#060;td&#062;" & myArray(0, i+CInt(intTotalRecords/2)) & "&#060;/td&#062;&#060;/tr&#062;") <BR>Next <BR>Response.Write("&#060;/table&#062;") <BR>%&#062; <BR><BR>Try that. <BR><BR>Craig.

5. Join Date
Dec 1969
Posts
86

## RE: Showing records

1. Do a count of the records (say n)<BR>2. Work out if n is odd or even<BR>3. If even then set blnEven to True and rows to n/2.<BR>4. If odd then set blnEven to False and rows to int(n/2) + 1<BR>5. Record recordset values within a locally declared array (eg <BR><BR>Dim i<BR>Dim name()<BR>i = 0<BR>Do Until oRs.EOF<BR>i = i + 1<BR>name(i) = oRs("Name" )<BR>Loop<BR><BR>6. Create another loop<BR><BR>If i &#060;&#062; 0 Then &#039;check for no names being output<BR>Response.Write "&#060;table&#062;"<BR>For i = 1 to rows<BR>Response.Write "&#060;tr&#062;&#060;td&#062;" & names(i) & "&#060;/td&#062;"<BR>If blnEven Then<BR>Response.Write "&#060;td&#062;" & names(i + rows) & "&#060;/td&#062;&#060;/tr&#062;<BR>Else<BR>Response.Write "&#060;td&#062;&#060;/td&#062;&#060;/tr&#062;"<BR>End If<BR>Next<BR>End If<BR><BR>Good luck!

6. Senior Member
Join Date
Dec 1969
Posts
1,913

## I HATE it when ...

I don&#039;t refresh the browser and see that the person has multiple posted and loads of replies have already been given.<BR><BR>Grrrrrrrr

7. Senior Member
Join Date
Dec 1969
Posts
16,931

## But you *were* bored...

and it gave you something to do :)<BR><BR>Craig.

8. Senior Member
Join Date
Dec 1969
Posts
1,913

## True , true but it's sooo embarrasing <e

.

9. Senior Member
Join Date
Dec 1969
Posts
433

## How baaad was that code.

I really should drink more coffee before posting on here.

10. Junior Member
Join Date
Dec 1969
Posts
13

## RE: True , true but it's sooo embarrasing �

If still bored &#060;% ;) %&#062;, you could help me with this?<BR>I need to mofidy this script, but I just don&#039;t where to start!<BR>(Started ASPing on monday...)<BR><BR>I need to get it like this:<BR><BR>&#060;table&#062;<BR>&#060;tr&#062;<B R>&#060;td&#062;&#060;input type="checkbox" value="Get ID from DB"&#062;&#060;/td&#062; <BR>&#060;td&#062;response.write Get NAME from DB&#060;/td&#062;<BR>rs.movenext<BR>LOOP<BR>&#060;/tr&#062;<BR><BR>And it should be printed the same <BR>way as in your example.<BR><BR>id1 name1 id4 name4<BR>id2 name2 id5 name5<BR>id3 name3 <BR><BR>What about if you could define the column number?<BR><BR>id1 name1 id4 name4 id7 name7<BR>id2 name2 id5 name5 id8 name8<BR>id3 name3 id6 name6<BR><BR>Does it get too complicated?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•