Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics 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 September 11th, 2007, 03:24 AM
Authorized User
 
Join Date: Jan 2007
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default looping

hi all and thanks for the support till now, i hope you all guys had a nice vacation.

here is the problem:

i have a table with the following columns:

PID, PName, PPID, Level. P: Property, PPID: ParentpropertyId

now i have the following properties:

human level 1
 man level 2 subcategories
 woman level 2 subcategories
Animals level 1
 cats level 2 subcategories
 dogs level 2 subcategories
plants

the question is that i want to dispaly them like this: property first and then subcategories according to the relative property, for that i create the following queries:

to display the property:

select PName from tblproperty where level = 1

to display the subcategories:

select PNAme from tblproperty where level = 2 and parentpropertyid <> propertyid

in this second query i'm getting all the subcategories.

i created also this 2 for loops:

for i = 0 to counter1
  show property
   for j = 0 to counter2
      show subcategories
    next
next

now i'm getting for everyone all the subcategories even for the ones that did not have subcategories like plants

the output i'm getting now is:

human level 1
 man level 2 subcategories
 woman level 2 subcategories
 cats level 2 subcategories
 dogs level 2 subcategories
Animals level 1
 man level 2 subcategories
 woman level 2 subcategories
 cats level 2 subcategories
 dogs level 2 subcategories
plants
 man level 2 subcategories
 woman level 2 subcategories
 cats level 2 subcategories
 dogs level 2 subcategories

any idea how i can solve this problem?
do i need to change my query or add something to my loop
the parent propertyid is just a column to link the subcategory to propert, so human has PID = 1 level 1 , then man has parentpropertyid = 1 and level = 2

thanks

Reply With Quote
  #2 (permalink)  
Old September 26th, 2007, 12:21 AM
Authorized User
 
Join Date: Dec 2006
Location: Mumbai, Maharastra, India.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default


In your Parent Query Add PID field also like this -

select PID,PName from tblproperty where level = 1

And in the Parent Loop use a variable to store value of PID. And in Inner Loop use this query -

select PNAme from tblproperty where parentpropertyid=variable_name_that_holds_parent_q ueries_PID_Value





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
Looping Code 2 takwirira Excel VBA 0 May 19th, 2008 06:39 AM
Looping ssaranam SQL Server 2005 2 April 17th, 2008 01:40 AM
Looping deepsea007 XSLT 1 June 14th, 2007 12:13 PM
Chapter 9 (Looping) Try It Out melbsurfer BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 2 January 27th, 2006 01:54 PM
Looping..? dedex C# 2 January 6th, 2005 11:24 PM



All times are GMT -4. The time now is 10:04 AM.


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