|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Assign Output to Specific Table Cells
How can I modify the page and hits output line below so that the output is forced into the appropriate table column accoring to the table column headings?
Thanks, Jason Code:
<CFQUERY NAME="Usage" DATASOURCE="courses">
SELECT
count (F05_253_stats_individual.Page) as Hits,
F05_253_stats_individual.Page,
F05_253_stats_individual.SID,
F05_253_grades.FirstName,
F05_253_grades.LastName
FROM
F05_253_stats_individual,
F05_253_grades
WHERE
F05_253_grades.SSN = F05_253_stats_individual.SID
GROUP BY
F05_253_stats_individual.SID,
F05_253_stats_individual.Page,
F05_253_grades.FirstName,
F05_253_grades.LastName
</CFQUERY>
<TABLE BORDER="1" CLASS="smalltext">
<TR>
<TD>Name</TD>
<TD>Home</TD>
<TD>Syllabus</TD>
<TD>EE Paper</TD>
<TD>Study Guides</TD>
<TD>Grades</TD>
<TD>About Me</TD>
</TR>
<CFOUTPUT QUERY="Usage" GROUP="SID">
<TR>
<TD><B>#FirstName# #LastName#</B></TD>
<CFOUTPUT>
<TD>#Page# #Hits#</TD>
</CFOUTPUT>
</TD></TR>
</CFOUTPUT>
</TABLE>
|
|
#2
|
|||
|
|||
|
I don't understand what you are asking.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
The code above produces a table like the one shown here (which just throws the output into table cells left to right with no regard for the corresponding column header):
![]() I want it to do something more like this, where it matches the output with the correct table column: ![]() Thanks, Jason |
|
#4
|
|||
|
|||
|
I'm still not sure I follow (why are there extra columns if there is no data in any of them?), but maybe this article I wrote a while back for Builder will help:
http://builder.com.com/5100-6389_14-5070836.html |
|
#5
|
|||
|
|||
|
Quote:
Yep, that's exactly what I need to do! The tutorial is a bit advanced for me, but I may be able to adapt it to my needs if I knew what the 3 queries should look like. I couldn't find them in the tutorial - am I missing something, or are example queries not provided with that tutorial? Thanks, Jason |
|
#6
|
|||
|
|||
|
One query contains what equates to the headers, one column contains what equates to the rows, and one has the data itself. So if you know what all possible columns are, and what all possible rows are, then you can individually go into the data query (or a structure holding that data, etc.) and look to see if there is data there.
I agree it is quite advanced and if you are new to CF I would recommend taking a simpler approach until you can generate the display that you really want. It can take some time to get comfortable with manipulating data and queries. Another option is to attack this from the query side, and ensure that a data value exists for every cell in the table. This usually requires outer joins, and is also rather complex depending on your data schema. |
|
#7
|
|||
|
|||
|
For anyone who comes upon this thread later, here is a fairly strightforward solution that a friend came up with for me:
Code:
<CFQUERY NAME="Usage" DATASOURCE="#request.dsn#">
SELECT count (#request.IndivStats#.Page) as Hits, #request.IndivStats#.Page, #request.IndivStats#.SID, #request.GradeTable#.FirstName, #request.GradeTable#.LastName
FROM #request.IndivStats#, #request.GradeTable#
WHERE #request.GradeTable#.SSN = #request.IndivStats#.SID
GROUP BY #request.IndivStats#.SID, #request.IndivStats#.Page, #request.GradeTable#.FirstName, #request.GradeTable#.LastName
ORDER BY #request.GradeTable#.LastName, #request.GradeTable#.FirstName, #request.IndivStats#.Page
</CFQUERY>
<TABLE WIDTH="650" BORDER="0" CLASS="smalltext" CELLPADDING="3" CELLSPACING="0">
<TR BGCOLOR="445891">
<TD ALIGN="left"><FONT COLOR="#FFFFFF"><B>Name</B></TD>
<TD ALIGN="center"><FONT COLOR="#FFFFFF"><B>Home</B></TD>
<TD ALIGN="center"><FONT COLOR="#FFFFFF"><B>Syllabus</B></TD>
<TD ALIGN="center"><FONT COLOR="#FFFFFF"><B>Paper</B></TD>
<TD ALIGN="center"><FONT COLOR="#FFFFFF"><B>Study Guide</B></TD>
<TD ALIGN="center"><FONT COLOR="#FFFFFF"><B>Grades</B></TD>
<TD ALIGN="center"><FONT COLOR="#FFFFFF"><B>About Me</B></TD>
<TD ALIGN="center"><FONT COLOR="#FFFFFF"><B>Unexpected</B></TD>
</TR>
<CFOUTPUT QUERY="Usage" GROUP="SID">
<TR BGCOLOR=###iif(Usage.currentrow MOD 2, DE('C9DAF0'), DE('E9EEF5'))#>
<TD><B>#LastName#, #FirstName#</B></TD>
<cfset Place_Home = " ">
<cfset Place_Syllabus = " ">
<cfset Place_EEPaper = " ">
<cfset Place_StudyGuides = " ">
<cfset Place_Grades = " ">
<cfset Place_AboutMe = " ">
<cfset Place_Unexpected = " ">
<CFOUTPUT>
<cfswitch expression="#Page#">
<cfcase value="AboutInstructor"><cfset Place_AboutMe = "#Hits#"></cfcase>
<cfcase value="Assignments"><cfset Place_EEPaper = "#Hits#"></cfcase>
<cfcase value="grades"><cfset Place_Grades = "#Hits#"></cfcase>
<cfcase value="Home"><cfset Place_Home = "#Hits#"></cfcase>
<cfcase value="StudyGuides"><cfset Place_StudyGuides = "#Hits#"></cfcase>
<cfcase value="Syllabus"><cfset Place_Syllabus = "#Hits#"></cfcase>
<cfdefaultcase ><cfset Place_Unexpected = Place_Unexpected & " #Page# #Hits#"></cfdefaultcase>
</cfswitch>
</CFOUTPUT>
<TD ALIGN="center">#Place_Home#</TD>
<TD ALIGN="center">#Place_Syllabus#</TD>
<TD ALIGN="center">#Place_EEPaper#</TD>
<TD ALIGN="center">#Place_StudyGuides#</TD>
<TD ALIGN="center">#Place_Grades#</TD>
<TD ALIGN="center">#Place_AboutMe#</TD>
<TD ALIGN="center">#Place_Unexpected#</TD>
</TR>
</CFOUTPUT>
</TABLE>
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Assign Output to Specific Table Cells |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|