<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="mmres://user_interface_reference.css" rel="stylesheet" type="text/css">
<title>CFLOOP: クエリーに対するループ</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
   <div id="説明">
   <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
      <tr> 
         <td valign="top" class="name">CFLOOP: クエリーに対するループ</td>
         <td valign="top" nowrap class="compatibility">&nbsp;</td>
      </tr>
      <tr>
         <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
      </tr>


    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">説明</span>
<p>
クエリーに対するループは、クエリーレコードセット内のレコードごとに実行されます。結果は cfoutput タグと同様です。ループが繰り返されるごとに、現在行の列が出力されます。このタイプの cfloop タグは、cfoutput タグ内で使用できないタグに対してループを行います。
</p>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="syntax"><span class="title">シンタックス</span><pre>&lt;cfloop
   query = &quot;query_name&quot;
   startRow = &quot;row_num&quot;
   endRow = &quot;row_num&quot;&gt;
&lt;/cfloop&gt;
</pre>    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">関連項目</span>
<p>
cfabort、cfbreak、cfexecute、cfexit、cfif、cflocation、cfoutput、cfswitch、cfthrow、cftry。詳細については、『ColdFusion MX 開発ガイド』の第2章の「CFML の要素」 の「cfloop と cfbreak」を参照してください。
</p>

<p>

</p>
    </td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="CLEARSEPARATION">&nbsp;</td>
  </tr>
  <tr>
    <td valign="top" colspan="2" class="description"><span class="title">例</span><pre>&lt;cfquery name = &quot;MessageRecords&quot;
dataSource = &quot;cfdocexamples&quot;&gt; 
SELECT * FROM Messages 
&lt;/cfquery&gt;
&lt;cfloop query = &quot;MessageRecords&quot;&gt; 
&lt;cfoutput&gt;#Message_ID#&lt;/cfoutput&gt;&lt;br&gt;
&lt;/cfloop&gt;
</pre>
<p>
cfloop タグでは、レコードセットの開始ポイントと終了ポイントをダイナミックに指定してループを繰り返すこともできます。これにより、後続の n セットのレコードをクエリーから取得します。この例では、MessageRecords クエリーで返される 5 番めのレコードから 10 番めのレコードまでループします。
</p>
<pre>&lt;cfset Start = 5&gt; 
&lt;cfset End = 10&gt; 
&lt;cfloop query = &quot;MessageRecords&quot; 
startRow = &quot;#Start#&quot; 
endRow = &quot;#End#&quot;&gt; 
&lt;cfoutput&gt;#MessageRecords.Message_ID#&lt;/cfoutput&gt;&lt;br&gt;
&lt;/cfloop&gt;
</pre>
<p>
レコードがなくなるか、現在のレコードのインデックスが endRow 属性の値を上回ると、ループは停止します。 
</p>

<p>
次の例では、cfinclude タグを使用して、ページ名リストのクエリーによって返されたページ群を 1 つのドキュメントに結合します。 
</p>
<pre>&lt;cfquery name = &quot;GetTemplate&quot;
dataSource = &quot;Library&quot;
maxRows = &quot;5&quot;&gt; 
SELECT TemplateName 
FROM Templates 
&lt;/cfquery&gt; 
&lt;cfloop query = &quot;GetTemplate&quot;&gt; 
&lt;cfinclude template = &quot;#TemplateName#&quot;&gt; 
&lt;/cfloop&gt; 
</pre>
         </td>
      </tr>
   </table>
   </div>
<div id="QUERY">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">QUERY</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">必須</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>ループを制御するためのクエリーです。 </p>

  </td>
  </tr>
  </table>
</div>
<div id="STARTROW">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">STARTROW</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">オプション</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>ループに含めるクエリーの最初の行です。 </p>

  </td>
  </tr>
  </table>
</div>
<div id="ENDROW">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>  
<td valign="top" class="name">ENDROW</td>
  <td valign="top" nowrap class="compatibility">&nbsp;</td>
  </tr>
  <tr>
  <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
  </tr>

  <tr>
  <td valign="top" class="syntax">&nbsp;</td>
  <td valign="top" nowrap class="requirements">オプション</td>
  </tr>
  <tr>
  <td colspan="2" class="clearseparation">&nbsp;</td>
  </tr>
  <tr>
  <td valign="top" colspan="2" class="description">



<p>ループに含めるクエリーの最後の行です。 </p>

  </td>
  </tr>
  </table>
</div>

  </body>
</html>
