Jump to content

column value increment function


paul2463

Recommended Posts

Hello Guys.

a simple question for all you friendly people out there who know more than me, or I would not be asking the question I would be answering myself...

I am setting up a very very simple auditing page for out internal electronic workshop, it has a mysql table back end, this table has a few fields but one of them is the "status" field, when a job is taken into the workshop it is set to default "0", when work actually starts the status goes up to "1", when testing starts it goes up to "2" and so on until it is handed back to the user....so every day we can can print out the status of all jobs in the workshop.

I would like to write a simple function that updates the value of "status" by incrementing it by 1 when certain buttons are pressed, here is my idea
[code]
function updateStatus($id) {

increment value of status by 1 where id = $id

}
[/code]

now for the question (got there eventually)

is there a sexy PHP/MySQL function to increment a table value by 1 or do i need to query the table to get the value, add 1 to it then update the table by setting the status field to the new value??

please be content that no animals will be hurt in the development of this function
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.