coldfusion - cfoutput 在一个文件名上循环

标签 coldfusion

根据LiveDocs for cfoutput in cf7 :

When you specify a query attribute, this tag loops over the query rows and produces output for each row within the range specified by the startRow and maxRows values

我正在尝试获取目录中文件的名称。我使用 cfdirectory 获取查询记录,然后使用 cfquery 查询该查询。我的 cfoutput 循环查询的行数,但每次都列出相同的文件名:

输出: alt text http://img80.imageshack.us/img80/9294/onefile.png

代码:

  <!-- list files in pass-fail directory -->
  <cfset fileLocation = "c:\YouTubeUploader\pass-fail">
  <cfdirectory 
    action = "list"
    directory = "#fileLocation#"
    name = "files"
    > <!-- master query -->

     <cfdump var="#files#" label="files in pass-fail" > 
      <!-- displays the query record set returned from cfdirectory -->

      <!-- detail query generates a new query result set - the names of the files  -->
        <cfquery dbtype="query" name="detail"> 
SELECT files.name
 FROM files
      </cfquery>

     <!-- output all file names -->
     <cfoutput query="detail"  startRow = "1"
            maxRows = "5">
     #files.Name#<br>  
       </cfoutput>

为什么 cfoutput 保留在那个文件名上?

最佳答案

原因是因为 cf 认为您需要文件查询的名称值,因为您在详细查询 files.name 中命名了变量。将您的详细信息查询更改为:

SELECT name FROM files

然后将您的内容更改为:

<cfoutput query="detail"  startRow = "1" maxRows = "5">#detail.name#<br></cfoutput>

一切都应该很酷。

关于coldfusion - cfoutput 在一个文件名上循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2463352/

相关文章:

jquery - 使用 AJAX 将表单数据发送到 Fw/1(Coldfusion) Controller 功能

coldfusion - 如何在字符串中的任意位置查找子字符串

coldfusion - 为什么我的启动 OpenOffice 服务的调用在开发中有效,但在服务器上无效?

sorting - 如何在 ColdFusion 7 中对查询对象进行排序?

sql-server - MS-SQL varchar(max) 数据类型的 CFQueryParam/cfsqltype

coldfusion - CFSpreadsheet 读取 - 更新到 Windows 10 后小数符号错误

coldfusion - 默认QuartzScheduler_Worker "Task invokehandler could not be chained"

memory-management - 是否可以确定 ColdFusion 中应用程序范围变量的大小(内存占用)?

coldfusion - Fusebox 在代码中调用 fuse

javascript - 使用 SerializeJSON 防止 ColdFusion 将字符串转换为数字