计算 cfoutput 内 cfoutput 的当前行

发布于 2024-12-07 21:21:33 字数 3633 浏览 0 评论 0原文

之后一切都会清楚:

<cfquery name="get_products" datasource="#dsn3#">
    SELECT P.PRODUCT_ID,P.PRODUCT_NAME,PS.MONEY,PR.PRICE,P.BRAND_ID,PS.PRICE,GSL.PRODUCT_STOCK,GSL.PURCHASE_ORDER_STOCK,GSL.SALEABLE_STOCK,P.PRODUCT_DETAIL2,P.BARCOD
    FROM PRODUCT P
        JOIN PRICE_STANDART PS ON P.PRODUCT_ID = PS.PRODUCT_ID
        JOIN PRICE PR ON P.PRODUCT_ID = PR.PRODUCT_ID
        JOIN #DSN2_ALIAS#.GET_STOCK_LAST GSL ON P.PRODUCT_ID = GSL.PRODUCT_ID
        <cfif isdefined('attributes.is_stock') and attributes.is_stock is 1>
            AND GSL.PRODUCT_STOCK > 0
        </cfif>
        <cfif isdefined('attributes.product_catid') and len(attributes.product_catid)>
            JOIN PRODUCT_CAT PC ON P.PRODUCT_CATID = PC.PRODUCT_CATID
        </cfif>
    WHERE PS.PURCHASESALES=1 AND PS.PRICESTANDART_STATUS=1 AND P.IS_SALES=1 AND P.IS_PURCHASE=1 AND P.IS_INTERNET=1 AND P.IS_EXTRANET=1
    AND PR.STARTDATE <= #now()# AND (PR.FINISHDATE >= #now()# OR PR.FINISHDATE IS NULL)

    GROUP BY P.PRODUCT_ID,PR.PRICE,P.PRODUCT_NAME,PS.MONEY,P.BRAND_ID,PS.PRICE,GSL.PRODUCT_STOCK,GSL.PURCHASE_ORDER_STOCK,GSL.SALEABLE_STOCK,P.PRODUCT_DETAIL2,P.BARCOD
    P.PRODUCT_ID, PR.PRICE DESC
</cfquery>

情况是这样的,我有一个显示一些值的表,而且另一个里面有一个 cfoutput,因此当前行是单独计算的,无论如何,我希望在 source:然后 table:

<cfoutput query="get_products" startrow="#attributes.startrow#" maxrows="#attributes.maxrows#" group="product_id">
        <tr height="20" onMouseOver="this.className='color-light';" onMouseOut="this.className='color-row';" class="color-row"> 
            <td>
                <a href="/index.cfm?fuseaction=product.form_upd_product&pid=#product_id#" style="color:blue;" target="_blank">#left(product_name,50)#</a>
            </td>
            <td>#left(PRODUCT_DETAIL2,50)#</td>
            <td align="center"><cfif len(brand_list)>#get_brands.brand_name[listfind(brand_list,brand_id,',')]#</cfif></td>
            <td align="center">#PRODUCT_STOCK#</td>
            <td align="center">#saleable_stock#</td>
            <td align="center">#purchase_order_stock#</td>
            <cfoutput><td align="center">#tlformat(price,2)# <cfif currentrow eq 4>asd</cfif></td></cfoutput>
            <td align="center"><a href="javascript://" onclick="gizle_goster(abr#currentrow#);" style="font-weight:bold;">x #saleable_stock#</a></td>
            <td align="center">#MONEY#</td>
        </tr>
        <tr onMouseOver="this.className='color-light';" onMouseOut="this.className='color-row';" class="color-row" id="abr#currentrow#" style="display:none;">
            <td colspan="3"></td>
            <td colspan="3" style="color:blue;font-weight:bold;text-align:center;">#saleable_stock# x</td>
            <cfoutput>
                <td align="center" style="color:red;font-weight:bold;text-align:center;">#tlformat((saleable_stock*price),2)#</td>
                <cfset abr = tlformat((saleable_stock*price),2)>
            </cfoutput>
            <td align="center" colspan="2">#MONEY#</td>
        </tr>
    </cfoutput>

和结果 http://s008.radikal.ru/i303/1110/2a/031496096958.png

可以看到写“asd”只显示在外面的第一行cfoutput,但是在cfoutput里面的第4行。 (一排有4个价格) 我想要的只是在外部 cfoutput 的每一行以及内部行的第四行中写入“asd”。

谢谢大家的帮助!

here is the situation, i have a table that displays some values, moreover there are one cfoutput inside the other, thus the currentrows are counted separately, anyway, i hope everything will be clear after source:

<cfquery name="get_products" datasource="#dsn3#">
    SELECT P.PRODUCT_ID,P.PRODUCT_NAME,PS.MONEY,PR.PRICE,P.BRAND_ID,PS.PRICE,GSL.PRODUCT_STOCK,GSL.PURCHASE_ORDER_STOCK,GSL.SALEABLE_STOCK,P.PRODUCT_DETAIL2,P.BARCOD
    FROM PRODUCT P
        JOIN PRICE_STANDART PS ON P.PRODUCT_ID = PS.PRODUCT_ID
        JOIN PRICE PR ON P.PRODUCT_ID = PR.PRODUCT_ID
        JOIN #DSN2_ALIAS#.GET_STOCK_LAST GSL ON P.PRODUCT_ID = GSL.PRODUCT_ID
        <cfif isdefined('attributes.is_stock') and attributes.is_stock is 1>
            AND GSL.PRODUCT_STOCK > 0
        </cfif>
        <cfif isdefined('attributes.product_catid') and len(attributes.product_catid)>
            JOIN PRODUCT_CAT PC ON P.PRODUCT_CATID = PC.PRODUCT_CATID
        </cfif>
    WHERE PS.PURCHASESALES=1 AND PS.PRICESTANDART_STATUS=1 AND P.IS_SALES=1 AND P.IS_PURCHASE=1 AND P.IS_INTERNET=1 AND P.IS_EXTRANET=1
    AND PR.STARTDATE <= #now()# AND (PR.FINISHDATE >= #now()# OR PR.FINISHDATE IS NULL)

    GROUP BY P.PRODUCT_ID,PR.PRICE,P.PRODUCT_NAME,PS.MONEY,P.BRAND_ID,PS.PRICE,GSL.PRODUCT_STOCK,GSL.PURCHASE_ORDER_STOCK,GSL.SALEABLE_STOCK,P.PRODUCT_DETAIL2,P.BARCOD
    P.PRODUCT_ID, PR.PRICE DESC
</cfquery>

then table:

<cfoutput query="get_products" startrow="#attributes.startrow#" maxrows="#attributes.maxrows#" group="product_id">
        <tr height="20" onMouseOver="this.className='color-light';" onMouseOut="this.className='color-row';" class="color-row"> 
            <td>
                <a href="/index.cfm?fuseaction=product.form_upd_product&pid=#product_id#" style="color:blue;" target="_blank">#left(product_name,50)#</a>
            </td>
            <td>#left(PRODUCT_DETAIL2,50)#</td>
            <td align="center"><cfif len(brand_list)>#get_brands.brand_name[listfind(brand_list,brand_id,',')]#</cfif></td>
            <td align="center">#PRODUCT_STOCK#</td>
            <td align="center">#saleable_stock#</td>
            <td align="center">#purchase_order_stock#</td>
            <cfoutput><td align="center">#tlformat(price,2)# <cfif currentrow eq 4>asd</cfif></td></cfoutput>
            <td align="center"><a href="javascript://" onclick="gizle_goster(abr#currentrow#);" style="font-weight:bold;">x #saleable_stock#</a></td>
            <td align="center">#MONEY#</td>
        </tr>
        <tr onMouseOver="this.className='color-light';" onMouseOut="this.className='color-row';" class="color-row" id="abr#currentrow#" style="display:none;">
            <td colspan="3"></td>
            <td colspan="3" style="color:blue;font-weight:bold;text-align:center;">#saleable_stock# x</td>
            <cfoutput>
                <td align="center" style="color:red;font-weight:bold;text-align:center;">#tlformat((saleable_stock*price),2)#</td>
                <cfset abr = tlformat((saleable_stock*price),2)>
            </cfoutput>
            <td align="center" colspan="2">#MONEY#</td>
        </tr>
    </cfoutput>

and the result:
http://s008.radikal.ru/i303/1110/2a/031496096958.png

as you can see writing "asd" is only displayed in the first row of the outside cfoutput, but in the 4th row of the inside cfoutput. ( there are 4 prices in one row )
All i want is to write the "asd" in every row of the outside cfoutput, and in the 4th row of the inside row.

Thank you all for the help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

转身以后 2024-12-14 21:21:33

当您进行分组输出时,CFQUERY 的 CURRENTROW var 的行为并不像您想象的那样。

最快的解决方案是在分组输出中设置并增加一个新变量,如下所示:

<cfset iter = 1 />
<cfoutput><td align="center">#tlformat(price,2)# <cfif iter eq 4>asd</cfif></td><cfset iter++ /></cfoutput>

请务必在任何新的分组输出开始时重置 var(因此请在第二个 行也是如此)。

When you do a grouped output, the CURRENTROW var of a CFQUERY doesn't behave like you would think.

The quickest solution would be to set and increment a new variable within your grouped output, here:

<cfset iter = 1 />
<cfoutput><td align="center">#tlformat(price,2)# <cfif iter eq 4>asd</cfif></td><cfset iter++ /></cfoutput>

Be sure to reset the var at the start of any new grouped output (so duplicate this code in your second <TR> row as well).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文