Inserting data from a form to a specific column in MySQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
implications
Forum Commoner
Posts: 25
Joined: Thu Apr 07, 2011 3:59 am

Inserting data from a form to a specific column in MySQL

Post by implications »

I have created a table in MySQL that consists of four columns.

Column 1 - Column 2 - Column 3 - Column 4

Of the four columns, column 1, 2 and 4 have already been filled and I want one of the forms to specifically insert data into Column 3 without affecting/replacing the data that is already present in the other columns. How would I go about inserting it into one of the rows but only inserting it into Column 3?
oscardog
Forum Contributor
Posts: 245
Joined: Thu Oct 23, 2008 4:43 pm

Re: Inserting data from a form to a specific column in MySQL

Post by oscardog »

Code: Select all

mysql_query("UPDATE your_table SET column3 = 'Your-Value-Here' WHERE your_primary_key_column = 'Row-Id");
If you simply want to update every single row, remove everything from 'WHERE' onwards.
Post Reply