update function...

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
welsh_sponger
Forum Newbie
Posts: 14
Joined: Fri Feb 03, 2006 7:46 am

update function...

Post by welsh_sponger »

I use this to insert data into my DB...

Code: Select all

<?php

$dblink = mysql_connect("localhost", "root", "password");

mysql_select_db("dbname", $dblink);

$query1 = "INSERT INTO sometable (field1)".
			"VALUES ('111234567890') " or die ("Unable to run query");

$dbresult = mysql_query($query1, $dblink);

mysql_close();

?>
If I want to update that same value, what is the command i use? I assume its some sort of UPDATE command, but cant seem to find what im looking for.

Thanks
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

these are basics, you have to learn from Mysql manual

Code: Select all

update table `sometable`
set
`fieldname1` = fieldvalue1,
`fieldname2` = fieldvalue2
where 
`fieldname1` = somepreviousfieldvalue
Post Reply