PHPsu
MANUAL ZH  |  EN
     


Current Position :| index>Beginners> PHP MySQL Update

PHP MySQL Update

FROM: AUTHOR: TIME:2008-04-25 HITS:

The UPDATE statement is used to modify data in a database table. www.phpsu.com


Update Data In a Database

The UPDATE statement is used to modify data in a database table.

do you kown phpsu.com?

Syntax

UPDATE table_name
SET column_name = new_value
WHERE column_name = some_value welcome to phpsu.com

Note: SQL statements are not case sensitive. UPDATE is the same as update.

To get PHP to execute the statement above we must use the mysql_query() function. This function is used to send a query or command to a MySQL connection.

phpsu.com is a free phpscool

Example

Earlier in the tutorial we created a table named "Person". Here is how it looks: phpsu提供的php教程

FirstName LastName Age
Peter Griffin 35
Glenn Quagmire 33

The following example updates some data in the "Person" table: phpsu.com

<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
} phpsu
mysql_select_db("my_db", $con);

mysql_query("UPDATE Person SET Age = '36'
WHERE FirstName = 'Peter' AND LastName = 'Griffin'");

do you kown phpsu.com?

mysql_close($con);
?> phpsu is a phpschool

After the update, the "Person" table will look like this: welcome to phpsu.com

FirstName LastName Age
Peter Griffin 36
Glenn Quagmire 33




TITLE:PHP MySQL Update
Copyright 2008 The PHPsu All rights reserved. This mirror generously provided by: .Hp Inc.
Last updated: Fri Jun 6 22:58:00 GMT-8 2008