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
https://forums.phpfreaks.com/topic/23641-column-value-increment-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.