Get ready for BLACK FRIDAY shopping starting in

Forums

PHP

This topic is locked

Increment a counter by a variable??

Posted 26 Feb 2008 00:44:56
1
has voted
26 Feb 2008 00:44:56 Patrick Houlihan posted:
A user submits a value that needs to be addedto the last value that is in the database, i.e. a rolling sum. So lets say, the first time one of my users uses this, they enter in a 34, OK 34 is stored in my database. Now the user enters in a 45, I need the database to get updated by an addition of the old value plus the new value, i.e. 34 + 45.

I can't figure out hwo to do this using PHP in dreamweaver. My db only gets updated with the last form value and not a rolling sum.

Any help woudl be greatly appreciated.

Thanks,

Patrick


Replies

Replied 26 Feb 2008 10:16:24
26 Feb 2008 10:16:24 Georgi Kralev replied:
Hi Patrick,

Check the following article:
www.articles-hub.com/Article/123298.html

It is for creating hit counter with PHP and mySQL. But the with little modification the code could be useful for your case.

For example in the following line instead adding 1 you can add your value:
mysql_query("UPDATE countertable SET count=count+1";

I hope this helps you.

Regards,

Georgi Kralev

Homepage: gdkralev.googlepages.com

Reply to this topic