1 Reply Latest reply on Aug 10, 2006 11:13 PM by Newsgroup_User

    Repeat region / looping with cfobject

    Level 7
      I apologize in advance, I am very new to CFCs.

      I invoked a cfc using <cfobject> to pull records from the database.
      What I need to know is where can I find information on how to loop the
      records from the cfc / database to show then on a page.

      Here is my object:

      <cfobject name="ProjectList" component="sf_main.components.SingleProjects">
      <cfset myProjects = ProjectList.ListProjects()>

      It pulls the first record just fine, but I need them all listed. Is there
      anything else I need to add to the object to be able to pull multiple
      records. If I were to do it using a <cfquery> I would just use the <cfoutput
      query="query_name">.

      Here is what I would like to loop:

      <table width="100%" border="0">
      <tr valign="top">
      <td width="5%" valign="middle"><div align="center">
      <form name="edit_project" id="edit_project"
      method="post"
      action="edit.cfm?project_id=<cfoutput>#myProjects.project_id#</cfoutput>">
      <input name="Edit_project" type="submit"
      class="maintext_small" id="Edit_project" value="Edit" />
      </form>
      </div></td>
      <td width="8%" valign="middle"><div align="center">
      <form name="removeproject" id="removeproject"
      method="post" action="">
      <input name="project_id" type="hidden" id="project_id"
      value="<cfoutput>#myProjects.project_id#</cfoutput>" />
      <input name="Submit" type="submit"
      class="maintext_small" value="Remove" />
      </form>
      </div></td>
      <td width="25%" valign="middle"
      class="maintext_btblue_bold"><a
      href="review.cfm?project_id=#myProjects.project_id#">#myProjects.title#</a></td>
      <td width="22%" valign="middle"><div align="left"
      class="maintext">#myProjects.company#</div></td>
      <td width="20%" valign="middle"><div align="center"
      class="maintext">#myProjects.projstatus#</div></td>
      <td width="15%" valign="middle"><div align="center"
      class="maintext">#DateFormat(myProjects.date,"mm/dd/yyyy")#</div>
      <div align="center"></div>
      <div align="center"></div></td>
      <td width="5%" valign="middle"><div align="center"><cfif
      #myProjects.live# EQ 1>
      <span class="maintext_btblue_bold">Yes</span>
      <cfelse>
      <span class="maintext_bold">No</span>
      </cfif>
      </div></td>
      </tr>
      </table>
      --
      Wally Kolcz
      Developer / Support