-1

someone can tell me how to update the value from 0 to 1, 52 to 53 (value++) using php script? i want to search it on go*gle but i dunno the keyword to find it

database.png

Flix
  • 444
  • 8
  • 20

3 Answers3

2

If you want to update one column, for example 5_sagnat_baik - just run the query:

UPDATE `question` SET `5_sagnat_baik` = `5_sagnat_baik` + 1
Battle Mage
  • 369
  • 2
  • 5
1
"UPDATE table_name
 SET column_name = column_name+ 1
 WHERE condition";

Hope this help

VishalParkash
  • 490
  • 3
  • 15
  • 1
    [Please stop using mysql_ functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php), as they have been removed from PHP – Machavity Oct 19 '16 at 12:40
1

You may update your auto-increment column (known as 'id') using a "update" sql in your php script using something like:

'UPDATE table_name SET id=(id + 1), [column2]=[value2], ...'

OR with PHP computed values (here $current_value):

'UPDATE table_name SET id=' . $current_value + 1 ', [column2]=[value2], ...'

The SQL update request is explained here: http://www.w3schools.com/SQl/sql_update.asp (or here: https://mariadb.com/kb/en/mariadb/update/#syntax)

user6815451
  • 31
  • 1
  • 5
  • 1
    Welcome to Stack Overflow, here [we do not like W3schools links](http://meta.stackoverflow.com/questions/280478/why-not-w3schools-com) but otherwise, great answer. :) – Sainan Oct 19 '16 at 11:48
  • @4796321 oh ok. Here is the SQL update reference then: https://mariadb.com/kb/en/mariadb/update/#syntax (I have edited the answer in consequence). – user6815451 Oct 19 '16 at 11:55