How do I update the contents of a table row?
And here is a simple one in action to show you how it works:
<?php
$query = "UPDATE mytable SET myname = 'Daniel' WHERE myname = 'Dan'";
?>
When executed that query will update every row in mytable that has a value of 'Dan' in the myname field to 'Daniel'.
Here we pick up on one of the dangers of UPDATE - (often) you only want to update one row, so make sure you specify clearly some unique way of identifying a row in the WHERE conditional, and often people add LIMIT 1 just in case!
Comment on this Question and Answer >>>
ASK A QUESTION
More mysql PHP Questions
how can I show an image from mysql?How do I set a default value for ENUM fields in PHP?
how to write sessions in php code?
How do I include a conditional in my mysql query?
how do i upload an image to database?
