aman1649 Posted January 6, 2011 Share Posted January 6, 2011 Hey guys, I am kind of new to php but I am stuck on this question. I have a mySQL database and table set up called members. I have some data in the table and I want to be able to add certain things to a paticular row in the table based off the ID number of the row. One of the values of the table is an auto incremeted ID number. I want to add a text value called message to a specified ID number. How do I go about doing that. I have this code already but it doesn't seem to work. $sql = "INSERT INTO members (message) VALUES ('$_POST[message]',(SELECT id FROM members WHERE id='$_POST[id]'))"; Any Ideas? Thanks Quote Link to comment Share on other sites More sharing options...
volatileboy Posted January 6, 2011 Share Posted January 6, 2011 "UPDATE table_name SET column_name='$newValue' WHERE id='$id'"; Quote Link to comment Share on other sites More sharing options...
Zurev Posted January 6, 2011 Share Posted January 6, 2011 "UPDATE table_name SET column_name='$newValue' WHERE id='$id'"; Right on, what volatileboy said. If you're ever trying to modify a row that already exists, even if it means inserting data into null/empty fields, it has to be update. Insert is only used when a completely new row is being created. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.