Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Output issue while grouping

New Here ,
Aug 10, 2008 Aug 10, 2008
OK guys... I have written a dynamic hierarchial menu that uses CSS. My issue is that I have 6 main menu items and each item has submenus. I have it ready to go in theory, but my cfoutput keeps repopulating the first entry.


I am hoping someone can help ASAP. I have 6 of the same thing.

JG
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Aug 11, 2008 Aug 11, 2008
jgethers wrote:
> It works well, except it doesnt output 2 3 4 5 6.

It never retrieves them in the first place. That is the problem, not the output.

Are there actually pagecontent records for parentID values 2, 3, 4, 5 and/or 6? If not, those those menu items will not appear in the results because you are using an INNER JOIN.

Try changing the INNER JOIN to a LEFT JOIN. That will include all records from the left hand table (ie cssmenu) even if there are no matching records in pagecontent ....
Translate
LEGEND ,
Aug 11, 2008 Aug 11, 2008
cfoutput has a group attribute. Usage is described in the cfml reference manual. If you don't have one, the internet does.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2008 Aug 11, 2008
Yeah... I tried that. <cfoutput query="populatemenu" group="mID"> (and tried cssmenu.mID)

Same thing.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 11, 2008 Aug 11, 2008
Your approach is all wrong. You put the group on the outer cfoutput. Then you put another cfoutput nested inside for the children. I think what I have done here will work?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2008 Aug 11, 2008
Simon now instead of the 6 I had before, I get 1

http://www.odcinc.com/new
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 11, 2008 Aug 11, 2008
Apparently I need to be authenticated to access that page, and without knowing what the data returned by the query looks like I cannot really help you further!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2008 Aug 11, 2008
No you dont. I was working on the web server. Try it again.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 11, 2008 Aug 11, 2008
When I hover over Employment I get 6?

assembly, bindery, mailings, inspection, vinyl, cheeseliners
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2008 Aug 11, 2008
I have 6 buttons across the top. It is only populating mID =1 there should be 5 more with menus
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 11, 2008 Aug 11, 2008
Can you dump that query somewhere so I can see it?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2008 Aug 11, 2008
I was trying to do it from the 1 query
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 11, 2008 Aug 11, 2008
I know that. But you know what the data in the query is and I don't which is the missing piece of the puzzle I need to help you.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2008 Aug 11, 2008
I am using the query you wrote.
<cfquery name="populatemenu" datasource="#DSN#">
SELECT cssmenu.mID,
pagecontent.parentID,
pagecontent.pname,
pagecontent.plink
FROM cssmenu
INNER JOIN pagecontent
ON cssmenu.mID = pagecontent.parentID
ORDER BY cssmenu.mID, pagecontent.parentID
</cfquery>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 11, 2008 Aug 11, 2008
I meant the query returned from the cfquery call:- populatemenu, what does populatemenu contain. So I wold like to see the rows and columns and what data they have in them?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 11, 2008 Aug 11, 2008
jgethers wrote:
> I am using the query you wrote....

Cfdump the query on your page so Stressed_Simon can see the results

<!--- Your page: http://www.odcinc.com/new --->

<!--- run the query --->
<cfquery name="populatemenu" datasource="#DSN#">
.... your query ....
</cfquery>

<!--- dump the results --->
<cfdump var="#populatemenu#">

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2008 Aug 11, 2008
http://odcinc.com/new/menu.cfm

That is where the cfdump is. It is only matching up mID 1
I have more in there like the number 2 has 1 child object.

So here is the deal. I have the 2 tables. 1 table has 6 items . These are the parent menus

The second table has the parentID field. This table also houses content for that page and the page name.

Sorry this took so long. It is hard to write code from my blackberry while installing servers.

John
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2008 Aug 11, 2008
I know this may sound funny, but can I cfloop the output to do what I want?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 11, 2008 Aug 11, 2008
jgethers wrote:
> I know this may sound funny, but can I cfloop the output to do what I want?

First figure out what is wrong with your query.

Look at the output. All of the mID and parentID values equal 1. I doubt that is correct, but given those results the cfoutput code is behaving correctly. It only produces 1 menu item because you are grouping by mID and there is only one mID value in the results. Either the data values in your tables are incorrect or your join/select statement is incorrect...
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2008 Aug 11, 2008
Well all of those Parent IDs are correct and they all are child objects of mID1. It works well, except it doesnt output 2 3 4 5 6.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 11, 2008 Aug 11, 2008
jgethers wrote:
> It works well, except it doesnt output 2 3 4 5 6.

It never retrieves them in the first place. That is the problem, not the output.

Are there actually pagecontent records for parentID values 2, 3, 4, 5 and/or 6? If not, those those menu items will not appear in the results because you are using an INNER JOIN.

Try changing the INNER JOIN to a LEFT JOIN. That will include all records from the left hand table (ie cssmenu) even if there are no matching records in pagecontent .

If that does not help, run a select on both tables separately and cfdump the results of the two queries.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 11, 2008 Aug 11, 2008
-==cfSearching==- wrote:
> If that does not help, run a select on both tables separately
> and cfdump the results of the two queries.

ie

<cfquery name="debugMenu" datasource="#DSN#">
SELECT *
FROM cssmenu
</cfquery>
<cfquery name="debugPageContent" datasource="#DSN#">
SELECT *
FROM pagecontent
</cfquery>

<cfdump var="#debugMenu#">
<cfdump var="#debugPageContent#">
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 11, 2008 Aug 11, 2008
> MID PARENTID PLINK PNAME
> 7 2 [empty string] [empty string] [empty string]
> 8 3 [empty string] [empty string] [empty string]
> 9 4 [empty string] [empty string] [empty string]
> 10 5 [empty string] [empty string] [empty string]
> 11 6 [empty string] [empty string] [empty string]

Yes, the problem is there are no matching pagecontent records for mID's 2, 3, ...6. Dump the pagecontent table. Are there just no records for those parentID's, are the parentID's wrong, etcetera... ?

BTW, should the SELECT really be returning the menu ID twice: mID and parentID column?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2008 Aug 11, 2008
ok left join outputs the 6 buttons but still only 1 child. It gives each menu a blank field.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2008 Aug 11, 2008
Nice. I had data in there, but when I changed the structure, I cleaned it up. Sorry man. 1 more question. How can I kill the output if it doesnt have a child object so I do not have empty menus?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 11, 2008 Aug 11, 2008
yes they are used to match the subs o the mains
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources