Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cfloop with table?

Status
Not open for further replies.

joelxez

Programmer
Apr 18, 2002
67
PH
Hi experts,

I have a code which suppose to be create an output with table. however it does'nt..pls help me



<cfparam name="ParentID" default="0">
<cfif IsDefined("Attributes.ParentID")>
<cfset ParentID = Attributes.ParentID >
</cfif>
<cfparam name="OrderBy" default="taskID">
<cfif IsDefined("Attributes.OrderBy")>
<cfset OrderBy = Attributes.OrderBy >
</cfif>

<cfquery name="GetCurrentID" datasource="promanager">
SELECT * FROM tbtask
WHERE taskparent =#ParentID# and projectID="#URL.prID#"
ORDER BY #OrderBy#;
</cfquery>
<!--- Loop through the query and display the taskname information.--->

<table align="left" border="1" cellpadding="" cellspacing="1">
<tr>
<ul>
<cfloop query="GetCurrentID">
<cfoutput>
<td width="700">
<li><font face="Verdana" size="1px"> #GetCurrentID.taskname#</font></li>
</td>
<td width="100">
#GetCurrentID.creatorID#
</td>

</cfoutput>
<!---Query items with ParentID equal to the current taskID.--->
<cfquery name="CheckForChild" datasource="promanager">
SELECT * FROM tbtask
WHERE taskparent = #GetCurrentID.taskID#;
</cfquery>
<!--- If CheckForChild returned records, then recurse sending the current
taskID as the ParentID.--->

<cfif CheckForChild.RecordCount gt 0 >
<tr>
<td width="600">
<cf_prjtask ParentID="#GetCurrentID.taskID#"
OrderBy="#OrderBy#">
</td>
</tr>
</cfif>


</cfloop>

</ul>
</tr>
</table>


Joel,
 
What doesn't it do? Are you trying to have an entire table for each record output, or just a new row? What exactly are you wanting it to do?



Hope This Helps!

Ecobb

&quot;My work is a game, a very serious game.&quot; - M.C. Escher
 
i just want to add new row actually, and arrange it by column.
something like this:

NAMES CREATOR

Animals 2
Cat 4
Dog 5
Doberman 1
Spaniel 7
Colors 1
Blue 4
Red 4
People 1
Bob 4
Steve 3
 
Ok, let's try this
Code:
<cfquery name="GetCurrentID" datasource="promanager">
SELECT * FROM tbtask    
WHERE taskparent =#ParentID# 
AND projectID="#URL.prID#"
ORDER BY    #OrderBy#
</cfquery>
<!--- Loop through the query and display the taskname information. --->

<table align="left" border="1" cellpadding="" cellspacing="1">
<cfoutput query="GetCurrentID">
	<tr>
		<td width="700">
		<font face="Verdana" size="1px"> #GetCurrentID.taskname#</font>
		</td>
		<td width="100">#GetCurrentID.creatorID#</td>
		
		<!---Query items with ParentID equal to the current taskID.--->    
		<cfquery name="CheckForChild" datasource="promanager">        
		SELECT * FROM tbtask        
		WHERE   taskparent = #GetCurrentID.taskID#   
		</cfquery>    
		<!--- If CheckForChild returned records, then recurse sending the current taskID as the ParentID.---> 
		<cfif CheckForChild.RecordCount gt 0 >  
		<tr>
		<td width="600">
		<cf_prjtask ParentID="#GetCurrentID.taskID#" OrderBy="#OrderBy#">
		</td>
		</cfif>
	</tr>
</cfoutput>
</table>

Let us know how this works.




Hope This Helps!

Ecobb

&quot;My work is a game, a very serious game.&quot; - M.C. Escher
 
Would this be helpful?

faq232-3697


DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
Code:
<cfquery name="GetCurrentID" datasource="promanager">
SELECT * FROM tbtask    
WHERE taskparent =#ParentID# 
AND projectID="#URL.prID#"
ORDER BY    #OrderBy#
</cfquery>
<!--- Loop through the query and display the taskname information. --->

<cfoutput query="GetCurrentID">
    <tr>
        <td width="700">
        <font face="Verdana" size="1px"> #GetCurrentID.taskname#</font>
        </td>
        <td width="100">#GetCurrentID.creatorID#</td>
        
        <!---Query items with ParentID equal to the current taskID.--->    
        <cfquery name="CheckForChild" datasource="promanager">        
        SELECT * FROM tbtask        
        WHERE   taskparent = #GetCurrentID.taskID#   
        </cfquery>    
        <!--- If CheckForChild returned records, then recurse sending the current taskID as the ParentID.---> 
        <cfif CheckForChild.RecordCount gt 0 >  
        <tr>
        <td width="600">
        <cf_prjtask ParentID="#GetCurrentID.taskID#" OrderBy="#OrderBy#">
        </td>
        </tr>
        </cfif>
</cfoutput>
</table>

That might work.

If not try this...

Code:
<cfquery name="GetCurrentID" datasource="promanager">
SELECT * FROM tbtask    
WHERE taskparent =#ParentID# 
AND projectID="#URL.prID#"
ORDER BY    #OrderBy#
</cfquery>
<!--- Loop through the query and display the taskname information. --->

<table align="left" border="1" cellpadding="" cellspacing="1">
<cfoutput query="GetCurrentID">
    <tr>
        <td width="700">
        <font face="Verdana" size="1px"> #GetCurrentID.taskname#</font>
        </td>
        <td width="100">#GetCurrentID.creatorID#</td>
        
        <!---Query items with ParentID equal to the current taskID.--->    
        <cfquery name="CheckForChild" datasource="promanager">        
        SELECT * FROM tbtask        
        WHERE   taskparent = #GetCurrentID.taskID#   
        </cfquery>    
        <!--- If CheckForChild returned records, then recurse sending the current taskID as the ParentID.---> 
        <cfif CheckForChild.RecordCount gt 0 >  
        <cf_prjtask ParentID="#GetCurrentID.taskID#" OrderBy="#OrderBy#">
        </cfif>
</cfoutput>

When you make the inital call to your tag which probably looks something like this..

Code:
<Cf_prjtask parentID="0" orderby="taskname">

change it to

Code:
<table align="left" border="1" cellpadding="" cellspacing="1">
  <Cf_prjtask parentID="0" orderby="taskname">
</table>

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top