|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Cfquery to html table with 3 columns
Newbie here --
I have seen how to display 3 output fields into and html table. However, I am wishing to display a single output field into an html table that is multiple columns wide (ex. 3) having dynamic rows depending on the number of fields returned. To site a simple example, an access table contains a record for each month of the year and a date on which the monthly meeting occurred....I would like to display across a 3column table each of those dates, January 23 Februrary 14 March 14 April 22 May 16 etc..... Thanks in advance |
|
#2
|
||||
|
||||
|
Well, I'm assuming that your query can result in more than 3 row, so then you will have multiple rows of 3.
try this: Code:
<cfquery name="Company_lookup" datasource="#variables.datasource#"> SELECT COMPANY FROM COMPANY_LOOKUP ORDER BY COMPANY </cfquery> <cfloop from="1" index="i" to="#Company_lookup.recordcount#" step="3"> <cfoutput> #Company_lookup.company[i]# <cfset i=i+1> #Company_lookup.company[i]# <cfset i=i+1> #Company_lookup.company[i]# </cfoutput> <br /> </cfloop>
__________________
The liver is evil and must be punished! |
|
#3
|
|||
|
|||
|
Thanks ebot - have created following code from your suggestion and i get error indicating mdate is not defined, yet a previous page executes properly...cannot see my error..
code modified per your suggestion: <cfquery name="getBoardMeetings" datasource="glenmore"> SELECT * FROM GCAtblBoardMeetings WHERE mdate < Now() ORDER BY mdate DESC </cfquery> <cfmodule template="../templates/headStart.cfm" title="Board Meeting Minutes"> <cfmodule template="../templates/headStop.cfm" title="Board Meeting Minutes" menuid="4"> </cfoutput> <cfloop from="1" index="i" to="#getBoardMeetings.recordcount#" step="3"> <cfoutput> #dateFormat(mdate[i],'mmmm d, yyyy')# <cfset i=i+1> #dateFormat(mdate[i],'mmmm d, yyyy')# <cfset i=i+1> #dateFormat(mdate[i],'mmmm d, yyyy')# </cfoutput> <br /> </cfloop> <cfmodule template="../templates/foot.cfm"> (the templates display properly) code that is working: <cfquery name="getBoardMeetings" datasource="glenmore"> SELECT * FROM GCAtblBoardMeetings WHERE mdate < Now() ORDER BY mdate DESC </cfquery> <cfmodule template="../templates/headStart.cfm" title="Board Meeting Minutes"> <cfmodule template="../templates/headStop.cfm" title="Board Meeting Minutes" menuid="4"> <ul> <cfloop query="getBoardMeetings"> <cfoutput> <li> <cfif #minutes# NEQ "not posted"> <a href="minutes/#minutes#">#dateFormat(mdate,'mmmm d, yyyy')#</a> <cfelse> #dateFormat(mdate,'mmmm d, yyyy')# - Not Yet Available </cfif> <cfif #trim(notes)# NEQ ""> <br /><em>#notes#</em> </cfif> <br /><br /> </li> </cfoutput> </cfloop> </ul> <cfmodule template="../templates/foot.cfm"> \\appreciate your help....bob |
|
#4
|
|||
|
|||
|
There is no mdate defined in the variables scope. You need to prefix anything related to the query with the name of the query:
<cfloop from="1" index="i" to="#getBoardMeetings.recordcount#" step="3"> <cfoutput> #dateFormat(getBoardMeetings.mdate[i],'mmmm d, yyyy')# <cfset i=i+1> #dateFormat(getBoardMeetings.mdate[i],'mmmm d, yyyy')# <cfset i=i+1> #dateFormat(getBoardMeetings.mdate[i],'mmmm d, yyyy')# </cfoutput> <br /> </cfloop>
__________________
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 |
|
#5
|
|||
|
|||
|
Kiteless,
Thanks so much...worked like a charm....is it possible for you to point me in the right direction to understand how to establish the variable scope you mention? Thanks in advance .. Kudos, Bob |
|
#6
|
|||
|
|||
|
The variables scope is the default ColdFusion scope. You don't have to do anything to create it; like all ColdFusion scopes it is created by the CF engine.
So you can do: <cfset you = "Bob" /> <cfset variables.me = "Brian" /> <cfset variables['kook'] = "Kim Jong Il" /> <cfdump var="#variables#" /> And see that all three are in the variables scope. |
|
#7
|
|||
|
|||
|
Thanks kite - appreciate your help.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Cfquery to html table with 3 columns |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|