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
|