PHP Questions Home | Register | Login
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website
Unanswered

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

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!



Comment on this Question and Answer >>>

ASK A QUESTION

More mysql PHP Questions

I am unable to make pages for my search result.Below I am giving the code that I am using. Career Search result Yami says

How do I find second highest value from a table?

My website www.quicheandpie.com has navigation buttons which were added by going to admin/categorylist and adding a category. I can add category = navigation buttons and update them, but I can not delete them. Any ideas how I can find where the info

How do I delete a row from a table?

What is difference between mysql_fetch_array and mysql_fetch_object?



Custom Search