![]() |
|
MySQL UPDATE Statement. Free online PHP and MySQL Web Database Programming Tutorial... |
| Lessons | MySQL UPDATE Statement |
|
|
UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value The WHERE clause in the UPDATE statement above specifies which record or records should be updated. If we omit the WHERE clause, all records will be updated or modified. In PHP we use the mysql_query() function to execute the above statements. Let's see an example: Example The following example updates some data in our "Students" table: <?php $con = mysql_connect("localhost", "adam" ,"ada"); if (!$con) { die('Error connecting database'); } mysql_query("UPDATE Students SET age = '25' WHERE name = 'Jacob'"); mysql_close($con); ?>
Next: PHP MySQL Delete
|