mjs87 Posted December 11, 2009 Share Posted December 11, 2009 Hi, I am fairly new to XML/XSL. I am trying to sum a variable that is within a for-each loop. The $subtotal variable is working out the total price for each product ordered on a invoice. Once all the products have been output I need to calculate the overall total price. I have tried to create a variable and increment it on each loop but you cannot change a variable once it has been set from what I have read. below just shows where I have just tried to sum the $subtotal variable...any ideas would be appreciated...thanks in advance <xsl:for-each select="DeliveryDetails/ProductOrder"> <tr align="center"> <td width="150"><xsl:value-of select="Description" /></td> <td width="150"><xsl:value-of select="ReferenceNo" /></td> <td width="100"><xsl:value-of select="Quantity" /></td> <td width="100">£<xsl:value-of select="Price" /></td> <td width="100">£ <xsl:variable name="subtotal" select="Quantity*Price" /><xsl:value-of select="$subtotal" /></td> </tr> </xsl:for-each> <xsl:value-of select="sum($subtotal)"/> Quote Link to comment https://forums.phpfreaks.com/topic/184793-xsl-total-variable/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.