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 Link to comment https://forums.phpfreaks.com/topic/223535-inserting-values-into-tables/ 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'"; Link to comment https://forums.phpfreaks.com/topic/223535-inserting-values-into-tables/#findComment-1155470 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. Link to comment https://forums.phpfreaks.com/topic/223535-inserting-values-into-tables/#findComment-1155502 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.