Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 4th, 2006, 11:54 PM
Registered User
 
Join Date: Jul 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with loop and array

I have a page that needs to display records in two columns. I have code written to pull the recordsets, turn it into an array, then divide it into two. It puts the first half in the first column, then the 2nd half in the 2nd column. There is a different number of records depending on the query. The problem is that when it gets to the second column, it is repeating the records.

Here is the code

  <%
dim aRS, x,y
aRS = RS.GetRows() ' Note this turns the Recordset into an array
RS.close ' We don't need the recordset anymore
x = ubound(aRS,2) / 2 ' get the midpoint of the array
y = 0
do while y < x
 if x + y < ubound(aRS,2) then
     response.write "<tr><td><b>" & aRS(1,y) & "</b>:&nbsp;" & aRS(2,y) & "</td><td><b>" & aRS(1,x+y) & ":</b>&nbsp;" & aRS(2,x+y) & "</td></tr>"
  else
     response.write "<tr bgcolor=""white""><td>" & aRS(1,y) & "</td><td>&nbsp;</td></tr>"
  end if

   y = y + 1
loop
%>

Reply With Quote
  #2 (permalink)  
Old July 5th, 2006, 11:24 PM
Friend of Wrox
 
Join Date: Oct 2003
Location: colombo, WP, Sri Lanka.
Posts: 481
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

hello,
use this code...

<% x=2
    reccount=rshomecount("gim")
    noofrows=reccount \ x
    balance=reccount mod x
%>
 <table border="0" width="100%">
<%for i=1 to noofrows%>
<tr>
<%for j=1 to x%>
<td width="<%=100/x%>%" valign="top">


        display
</td>
<%
rshome.MoveNext()
next%>
</tr>
<%next%>

<tr>
<%for j=1 to balance%>
<td valign="top">

    display

</td>
<%
rshome.MoveNext()
next%>
<td colspan="<%=(x-balance)%>" width></td>
</tr>
</table>


surendran
(Anything is Possible)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Array and Loop ublend Classic ASP Professional 2 November 21st, 2007 07:50 AM
loop array problem dbrine Java Basics 2 June 15th, 2007 06:49 AM
Pass variables from array inside a loop dustygn PHP How-To 2 May 3rd, 2006 05:35 PM
create array for loop in FSO jfergy Classic ASP Professional 4 April 14th, 2006 09:59 PM



All times are GMT -4. The time now is 05:15 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.