Advertisement

07.12.2008 at 09:33PM PDT, ID: 23560358
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.1

Count(*) all items in categories AND subcategories

Asked by ChristinaPupo in Active Server Pages (ASP), Web Languages/Standards, Microsoft Access Database

Tags:

Hi,  I have a function that I have been trying to alter to count all the products in a category including their sub-categories. I have been able to get the count to work 1 level deep but if the category has sub-categories that also have sub-categories then the count doesnt show. The follow code is working 1 level deep. I know there is probably a better way to go about this but I haven't been able to get COUNT(*) to work due to my inexperience. Here is the function:

Any help is appreciated!Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
function expandCategory(IDCategory,tempStr) 
     dim mySQL, rsTemp, catArr, row 
     'Get Sub-Categories 
	mySQL = "SELECT idCategory, categoryDesc,categoryHTML," _
		  & "      (SELECT COUNT(*) " _
		  & "       FROM   products, categories_products " _
		  & "       WHERE  products.idProduct = categories_products.idProduct " _
		  & "       AND    categories_products.idCategory = categories.idCategory " _ 
		  & "       AND    active = -1) " _
		  & "       AS     prodCount " _
		  & "FROM   categories " _
		  & "WHERE  idParentcategory = " & validSQL(idCategory,"I") & " " _
		  & "ORDER BY sortOrder, categoryDesc "
	set rsTemp = openRSexecute(mySQL)
	if not rsTemp.EOF then
 
           '- catArr(0,row) = idCategory 
           '- catArr(1,row) = categoryDesc 
           '- catArr(2,row) = categoryHTML 
           '- catArr(3,row) = prodCount 
 
           catArr = rsTemp.getRows() 
           
     end if 
     call closeRS(rsTemp) 
      
'Show Sub-Categories 
   dim intMaxRow 
   dim intRowCounter 
   dim colPerc 
 
   intMaxRow = 3   'NUMBER OF COLUMNS 
   intRowCounter = 0 
   colPerc = 100/intMaxRow 'This will set the width of the cell on the <TD> to show uniformity 
 
    if isArray(catArr) then 
       for row = 0 to UBound(catArr,2) 
     if intRowCounter = 0 then 
      tempStr = tempStr & "<tr>" 
     end if 
     intRowCounter = intRowCounter + 1 
        tempStr = tempStr & "<td width='" & colPerc & "%' align='center' valign='top'><b><a href= ""prodList.asp?idcategory=" & catArr(0,row) & """>" & catArr(2,row) & "<br>" & catArr(1,row) & "</a></b>" 
If catArr(3,row) > 0 then 
tempStr = tempStr & "<br>(" & catArr(3,row) & ")</span></td>" & vbCrLf
else 
	'ADDED BY CHRISTINA TO COUNT ALL PRODUCTS IN SUBCATEGORIES
	DIM rsCount, catArr2, prodTotalCount, rec_count
	rec_count = 0
	'WORKING 1 LEVEL DEEP
	mySQL = "SELECT products.idProduct " _
		  & "       FROM   products, categories_products, categories " _
		  & "       WHERE  products.idProduct = categories_products.idProduct " _
		  & "       AND    categories_products.idCategory = categories.idCategory " _ 
		  & "       AND    categories.idParentcategory = " & catArr(0,row) & " " _
		  & "       AND    active = -1 "
	set rsCount = openRSexecute(mySQL)
	do while not rsCount.eof
	rsCount.MoveNext
	rec_count = rec_count + 1
	loop
call closeRS(rsCount)
tempStr = tempStr & "<br>(" & rec_count & ")</td>"  & vbCrLf
end if 
     if intRowCounter = intMaxRow then 
      intRowCounter = 0 
      tempStr = tempStr & "</tr>"  & vbCrLf
     end if 
      next 
end if 
     expandCategory = tempStr 
end function
[+][-]07.13.2008 at 11:01AM PDT, ID: 21993490

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.13.2008 at 12:09PM PDT, ID: 21993764

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.13.2008 at 12:10PM PDT, ID: 21993770

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.13.2008 at 12:11PM PDT, ID: 21993773

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Active Server Pages (ASP), Web Languages/Standards, Microsoft Access Database
Tags: ASP, VBScript
Sign Up Now!
Solution Provided By: GRayL
Participating Experts: 3
Solution Grade: A
 
 
[+][-]07.13.2008 at 06:28PM PDT, ID: 21995089

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.13.2008 at 06:50PM PDT, ID: 21995144

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.13.2008 at 07:07PM PDT, ID: 21995190

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.13.2008 at 07:25PM PDT, ID: 21995260

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.14.2008 at 03:13AM PDT, ID: 21996827

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.14.2008 at 11:53AM PDT, ID: 22000878

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628