RE: [PHP] Adding to a MySql Database
[snip] I have a field on a MySql database that is started with a 0, and I want to add 1 to this field every time a button is pressed on a form. So it should add one every time, like if there is 5 and you press it one time it would have 6. [/snip] 1. SELECT for the current value 2. add 1 to the current value 3. UPDATE the new value HTH! Jay I ain't gonna write your code for ya' or fix your computer neither * * Texas PHP Developers Conf Spring 2003* * T Bar M Resort Conference Center* * New Braunfels, Texas * * Contact [EMAIL PROTECTED] * * * * Want to present a paper or workshop? Contact now! * * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding to a MySql Database
Or better UPDATE table SET col = col +1 Jay Blanchard wrote: [snip] I have a field on a MySql database that is started with a 0, and I want to add 1 to this field every time a button is pressed on a form. So it should add one every time, like if there is 5 and you press it one time it would have 6. [/snip] 1. SELECT for the current value 2. add 1 to the current value 3. UPDATE the new value HTH! Jay I ain't gonna write your code for ya' or fix your computer neither * * Texas PHP Developers Conf Spring 2003* * T Bar M Resort Conference Center* * New Braunfels, Texas * * Contact [EMAIL PROTECTED] * * * * Want to present a paper or workshop? Contact now! * * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding to a MySql Database
Marek's a bit more elegant, but I'm wondering when twelve of us press the button and the database is hit bang, bang, bang. Mightn't a MySQL autoincrement field be better, and let MySQL do the work? mt At 07:32 PM 9/24/2002 +0200, Marek Kilimajer wrote: Or better UPDATE table SET col = col +1 Jay Blanchard wrote: [snip] I have a field on a MySql database that is started with a 0, and I want to add 1 to this field every time a button is pressed on a form. So it should add one every time, like if there is 5 and you press it one time it would have 6. [/snip] 1. SELECT for the current value 2. add 1 to the current value 3. UPDATE the new value HTH! Jay I ain't gonna write your code for ya' or fix your computer neither * * Texas PHP Developers Conf Spring 2003* * T Bar M Resort Conference Center* * New Braunfels, Texas * * Contact [EMAIL PROTECTED] * * * * Want to present a paper or workshop? Contact now! * * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding to a MySql Database
I agree mt, LET MYSQL DO THE JOB !! Marek's a bit more elegant, but I'm wondering when twelve of us press the button and the database is hit bang, bang, bang. Mightn't a MySQL autoincrement field be better, and let MySQL do the work? mt At 07:32 PM 9/24/2002 +0200, Marek Kilimajer wrote: Or better UPDATE table SET col = col +1 Jay Blanchard wrote: [snip] I have a field on a MySql database that is started with a 0, and I want to add 1 to this field every time a button is pressed on a form. So it should add one every time, like if there is 5 and you press it one time it would have 6. [/snip] 1. SELECT for the current value 2. add 1 to the current value 3. UPDATE the new value HTH! Jay I ain't gonna write your code for ya' or fix your computer neither * * Texas PHP Developers Conf Spring 2003* * T Bar M Resort Conference Center* * New Braunfels, Texas * * Contact [EMAIL PROTECTED] * * * * Want to present a paper or workshop? Contact now! * * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding to a MySql Database
On Tue, 24 Sep 2002, The New Source wrote: -I have a field on a MySql database that is started with a 0, and I want -to add 1 to this field every time a button is pressed on a form. So it -should add one every time, like if there is 5 and you press it one time -it would have 6. - UPDATE table SET field = field + 1 WHERE whatever = whatever; ** John Huggins VANet [EMAIL PROTECTED] http://www.va.net/ ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adding to a MySql Database
on 25/09/02 3:05 AM, The New Source ([EMAIL PROTECTED]) wrote: I have a field on a MySql database that is started with a 0, and I want to add 1 to this field every time a button is pressed on a form. So it should add one every time, like if there is 5 and you press it one time it would have 6. UPDATE tablename SET value=value+1 WHERE . Or something like that!! Check the MySQL manual. Justin French -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php