Hello. I have a form which will do some simple maths from the users inputs and insert it into the database with their record. Only way I can work it out is to put some code on the page they're taken to after submitting. Like this: UPDATE table SET table.total = (table.input1 * table.input2) This works but updates the whole table of course. I've been trying this to take the last record entered via a timestamp but it isn't working. UPDATE table SET table.total = (table.input1 * table.input2) ORDER BY table.updatetimestamp DESC LIMIT 0,1 Can anyone tell me how it should be done please? Thanks. Jamie.
You are going to need to use a WHERE clause in your UPDATE query and either a sub-query or second query to identify which row to update. I'll generally explain how to do it with a second query: First run a query to identify the maximum value of the updatetimestamp column. Once you have that specific value, run your UPDATE query using that value as part of the WHERE clause.