PHP Questions Home

Categories

Arrays
Files
Forms
Functions
Images
MySQL
Numbers
Others
Strings
Website


PHP Functions

PHP Functions


More PHP

Top Questions
Ask a Question

How do I update the contents of a table row?


Updating the contents of a table row is done using an UPDATE mysql query.

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!



More mysql PHP Questions

How do I group the results of a mysql query?
How do I limit the number of rows returned?
How do I return the date with mySQL?
How do I delete a row from a table?
How do I access the current time with mysql?