![]() |
Is This Possible?
Hi everyone,
I'm trying to insert data into a database which has part of a row filled in and part empty. For example, my database has the following structure: userID, user_name, user_pass, user_confirm_pass, user_email, user_address and user_postcode. All of the data is filled in except user_address and user_postcode. I have a section on the website that allows the user to fill in these details and then submit them to the database, but I can't get it working. I think it's because as I said, part of the row is already filled it. Is is possible to add data to a row which already contains some data? Thanks in advance, Steven |
If I understand what you mean, you just need to look at mysql update.
More info here: PHP MySQL Update |
You understood it as I understood it, Jmz. So I think you're right in saying the
UPDATE keyword will allow you to do just that.sql Code:
|
Hi guys,
Sorry I didn't explain it very well, this is what I mean. My database looks like this at the moment: http://img229.imageshack.us/img229/2905/dbqh5.jpg Now at a future date I would like to update user_address and user_postcode without changing any other data. I have the query and everything else set up, but I'm not sure if I can actually add data to part of a row which is empty. |
Yes, you can, using the UPDATE query that everybody has been describing above. ;-) It permits for changing data or adding new data to an existing row without deleting old existing data.
-m |
Thank guys! I had actually tried that before but I was using the wrong syntax for my query.
Cheers, Steven |
i understood what you want, your basically writing a update statement and in this statement your putting all the column names whether its empty or with data and setting the data to update based on what was entered on the webpage.
to allow an empty field to update as empty make sure that column or field doesnt have the not null selected so that you will be able to update it witout data. im thinking that you used the update or insert statement and had set the column to not null and that when you tried to insert or update you were getting errors. |
He could also choose just to update the fields who actually is different :)
|
| All times are GMT. The time now is 12:42 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0