TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Is This Possible? (http://www.talkphp.com/absolute-beginners/2867-possible.html)

StevenF 05-30-2008 08:08 PM

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

Jmz 05-30-2008 08:16 PM

If I understand what you mean, you just need to look at mysql update.

More info here: PHP MySQL Update

Wildhoney 05-30-2008 08:52 PM

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:
UPDATE myTable SET myNameRow = 'Adam' WHERE myIdRow = 5

StevenF 05-31-2008 08:41 PM

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.

delayedinsanity 05-31-2008 08:47 PM

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

StevenF 05-31-2008 11:06 PM

Thank guys! I had actually tried that before but I was using the wrong syntax for my query.

Cheers,
Steven

sarmenhb 06-01-2008 05:58 PM

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.

SpYkE112 06-01-2008 08:13 PM

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