Page 1 of 1

update function...

Posted: Fri Feb 24, 2006 7:47 am
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

Posted: Fri Feb 24, 2006 8:59 am
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