I'm working on a web based IT knowledbase type app for my personal use. I'm trying to accomplish something I have seen on other websites. I have a DB with two tables. One table has all the different categories and their category id, and the other table has a the actual content, category ID, etc. (Look at the attached code below and look at the CFQUERY pulling out of the KNOWLEDGEBASE table)
If you go to you will see the template I am working on. You'll notice the (0) next to each category. What I want to do, is query the KNOWLEDGEBASE table and count how many articles I have stored in the DB for each CATEGORY. Then next to each category have a number displaying how many articles for that CATEGORY are stored in the DB.
I have tried a few different ways but I really came up with nothing that works. I am assuming there's some type of CFLOOP needed which I am really awful with.
If someone has a piece of code available that could help me out I would greatly appreciate it.
Thanks!
George
<CFQUERY NAME="CATZ" DATASOURCE="GLKB">
Select CATID, CATEGORY
From CATEGORIES
Order By CATEGORY
</CFQUERY>
<CFQUERY NAME="NUMZ" DATASOURCE="GLKB">
Select CONTENTID, CATEGORY, SUBJECT, CONTENT, DATE, EDIT
From KNOWLEDGEBASE
</CFQUERY>
<HTML>
<HEAD>
<TITLE>Categories</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="stylesheet" HREF="glcss.css" TYPE="TEXT/CSS">
</HEAD>
<TABLE WIDTH="525" CELLSPACING="3" CELLPADDING="3">
<TR>
<CFOUTPUT QUERY="CATZ">
<TD><A HREF="catpage.cfm?CATID=#CATZ.CATID#">#CATEGORY#</A> (0)<BR>
</TD>
<CFIF CATZ.CURRENTROW MOD 2 IS 0>
</TR>
<TR>
</CFIF>
</CFOUTPUT>
</TABLE>
</BODY>
</HTML>
If you go to you will see the template I am working on. You'll notice the (0) next to each category. What I want to do, is query the KNOWLEDGEBASE table and count how many articles I have stored in the DB for each CATEGORY. Then next to each category have a number displaying how many articles for that CATEGORY are stored in the DB.
I have tried a few different ways but I really came up with nothing that works. I am assuming there's some type of CFLOOP needed which I am really awful with.
If someone has a piece of code available that could help me out I would greatly appreciate it.
Thanks!
George
<CFQUERY NAME="CATZ" DATASOURCE="GLKB">
Select CATID, CATEGORY
From CATEGORIES
Order By CATEGORY
</CFQUERY>
<CFQUERY NAME="NUMZ" DATASOURCE="GLKB">
Select CONTENTID, CATEGORY, SUBJECT, CONTENT, DATE, EDIT
From KNOWLEDGEBASE
</CFQUERY>
<HTML>
<HEAD>
<TITLE>Categories</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="stylesheet" HREF="glcss.css" TYPE="TEXT/CSS">
</HEAD>
<TABLE WIDTH="525" CELLSPACING="3" CELLPADDING="3">
<TR>
<CFOUTPUT QUERY="CATZ">
<TD><A HREF="catpage.cfm?CATID=#CATZ.CATID#">#CATEGORY#</A> (0)<BR>
</TD>
<CFIF CATZ.CURRENTROW MOD 2 IS 0>
</TR>
<TR>
</CFIF>
</CFOUTPUT>
</TABLE>
</BODY>
</HTML>