views:

48

answers:

2

For example, I know I can make a new row and enter values into all fields doing this:

mysql_query('INSERT INTO table_name VALUES ( "id77" ,"some value" )');

Assuming the name of the first field ("id77") is "myID" and the name of the second field ("some value") is "foo"...

How can I use PHP find the row with myID = id77 and change the "foo" value to "bar"?

+6  A: 

UPDATE ... WHERE.

You should read some books on MySQL first.

FractalizeR
Yes, that worked, thanks for the answer. :) Eventually, I will read the book; however, I do not have time to do that this morning.
;) You are welcome. If you have no books, MySQL online documentation is also ok.
FractalizeR
+1  A: 
mysql_query("UPDATE table_name SET foo = 'bar' WHERE myID = 77");

I assume that you are using an integer (77) for your IDs instead of a string value ("id77").

Alex