paul2463 Posted October 11, 2006 Share Posted October 11, 2006 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 Quote Link to comment Share on other sites More sharing options...
printf Posted October 11, 2006 Share Posted October 11, 2006 Somthing like..[code]UPDATE table SET status = (status + 1) WHERE work_order = some_id;[/code]Where...work_order = would be changed to match your column name that identifies each row!some_id = the id that identifies what row you want to update!me! Quote Link to comment Share on other sites More sharing options...
TEENFRONT Posted October 11, 2006 Share Posted October 11, 2006 set the colum value to auto increment ( do this in phpmyadmin when creating the columns ) and set the id as your primary key :) Quote Link to comment Share on other sites More sharing options...
paul2463 Posted October 11, 2006 Author Share Posted October 11, 2006 thanks printfa one line function...love it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.