Hi;<br>I have the following code:<br><br> for row in data:<br> i += 1<br> total = 0<br> quantity = form.getfirst('order_' + str(i), '')<br> if quantity != '':<br> sql = 'select * from products p join %s c on p.ID=c.ID where c.ID=%s;' % (client, str(i))<br>
cursor.execute(sql)<br> stuff = cursor.fetchone()<br> price = str(int(stuff[5]*100))<br> price = price[0:len(price)-2] + '.' + price[-2:]<br> item, price, description, discount = stuff[2], price, stuff[3], stuff[8]<br>
order += 'Item #: ' + item + '\tQuantity: ' + quantity + '\tPrice: ' + price + '\tDiscount: ' + str(discount) + '\tDescription: ' + description[:20] + '...<br />\n'<br>
print 'Total 1: %s<br />' % total<br> total += float(price) * int(quantity) * (100 - discount)/100<br> print 'Total 2: %s<br />' % total<br> order += 'TOTAL: $' + str(total)<br>
<br>It prints out the following to screen with the print statements:<br><br>Total 1: 0<br>
Total 2: 1.98<br>
Total 1: 0<br>
Total 2: 6.3<br><br>As you can see, the total doesn't accumulate! There are two rows. The second "Total 1:" should show "1.98", not 0! What gives?<br>TIA,<br>Victor<br>