This looks like sudo code so I won't respond with code.
Create a connection to database
Use open db to make query
Close db
Return relevant data if necessary.
These are the steps you need to take in order to do an "update" function, which is assumed to a database.
If you have troubles with the steps then post your actual code and we can go from there b