Cfoutput Group Prices
i want to group prices according to products id, like here: http://s44.radikal.ru/i106/1108/57/33380d0557f4.jpg but i can't group them properly, there are must be one product and f
Solution 1:
Assuming you have a query that looks like this:
product_id, product_name, price
1, 'test', 100
1, 'test', 200
1, 'test', 300
2, 'test2', 100
2, 'test2', 200
2, 'test2', 300
The following code would group by product id and output each individual price
<cfoutputquery="get_products"group="product_id">
#product_name#
Prices:
<cfoutput>
#price#<br></cfoutput></cfoutput>
Now, the group by in sql has nothing to do with coldfusions group in cfoutput. It's a convinience method to loop out unique rows. So when coldfusion sees two identical "product_id" it will run the nested cfoutput loop.
You can do this for as many levels you want, but in your case there only seems to be two.
Post a Comment for "Cfoutput Group Prices"