Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Add/subtract from a database value

by LeGo (Chaplain)
on Jul 06, 2001 at 04:26 UTC ( [id://94352]=note: print w/replies, xml ) Need Help??


in reply to Add/subtract from a database value

Would something like this help? Just use those commands and adapt.
$dbh = DBI->connect( "dbi:mysql:user", "webserver", "pwd") or dienice( +"Can't connect: ",$dbh->errstr); my $sub = param("sub"); my $add = param("add"); if($add){ $sth = $dbh->do("update database set count=count+$add where address +=\"$whatever\"") } if($sub){ $sth = $dbh->do("update database set count=count-$sub where address +=\"$whatever\"") }

Feel free to update this or correct this as this is the way I do things and if there is a better way or something that I am missing please do let me know.

LeGo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://94352]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2025-02-07 05:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (94 votes). Check out past polls.