Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 5th, 2005, 03:35 AM
Authorized User
 
Join Date: May 2004
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default While loop urgent

i have table name loan with 2 columns
while i retrieved and using recordset i got the result like the below list
<%
While not rs.eof
response.write rs(0) & "- " rs(1)
rs.movenext
wend
%>
Result is
Personal Loan – PLType1
Personal Loan – PLType 2
Personal Loan – PLType 3
Personal Loan – PLType 4
Home Loan - HLType1
Home Loan - HLType2

now i need to display the result as

Personal Loan(PLType1/PLType2/PLType3/PLType4)
Home Loan(HLType1/HLType2)

Could any one help to make the result


 
Old October 7th, 2005, 03:04 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii mikedeepak!!
Plz try this,
Currently I do not have any database on my system :)
So I use array instead of your recordset.

Note:-rs(0) -stands for arrname
      rs(1) -stands for arrvalue

<%
dim arrname(5)
dim arrvalue(5)
arrname(0)="Personal Loan"
arrname(1)="Personal Loan"
arrname(2)="Personal Loan"
arrname(3)="Personal Loan"
arrname(4)="Home Loan"
arrname(5)="Home Loan"

arrvalue(0)="PLType1"
arrvalue(1)="PLType2"
arrvalue(2)="PLType3"
arrvalue(3)="PLType4"
arrvalue(4)="HLType1"
arrvalue(5)="HLType2"

searchstr=""
output=""
prevsearchstr=""
for i=0 to ubound(arrname)


if(searchstr="") then 'first time getting value
    output=output & arrname(i) &"(" &arrvalue(i)
    prevsearchstr=arrname(i)

        searchstr=arrname(i)
else
        if(prevsearchstr=arrname(i)) then
      output=output & "/"& arrvalue(i)
     prevsearchstr=arrname(i)

    else
        output=output & ")"
                   response.write(output &"<br>")
                    output= arrname(i) &"(" &arrvalue(i)
                    prevsearchstr=arrname(i)
                        searchstr=arrname(i)

          end if

end if

if(i=ubound(arrname)) then
 response.write(output&")")
end if

next
%>

Hope this will help you

Cheers :)

vinod





Similar Threads
Thread Thread Starter Forum Replies Last Post
URGENT:For loop jyoti_khera XSLT 3 October 19th, 2004 08:04 AM
Do Loop junemo Beginning PHP 8 July 28th, 2004 02:58 AM
Problem with Loop?? Please URGENT peterallcdn Beginning PHP 1 November 27th, 2003 06:37 PM
nested while loop doesn't loop hosefo81 PHP Databases 5 November 12th, 2003 08:46 AM





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