计算 cfoutput 内 cfoutput 的当前行
之后一切都会清楚:
<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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您进行分组输出时,CFQUERY 的 CURRENTROW var 的行为并不像您想象的那样。
最快的解决方案是在分组输出中设置并增加一个新变量,如下所示:
请务必在任何新的分组输出开始时重置 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:
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).