views:

38

answers:

5

Hello,

I have this form on my site where a user can enter many strings and save it to their account. But I'm not sure how to go about it.

Instead of creating a whole new user, with new values, I'd just like to update a single entry in the database.

For example if a user wanted to add another email address to their account, how would I sort of create an array, and add that to their existing space in the database?

Thank you

+1  A: 

are you looking for Update query in SQL

UPDATE [Cube].[dbo].[IdentityCheck]
   SET [Name] = <Name, text,>
 WHERE <Search Conditions,,>
anishmarokey
I have absolutely no idea what the first line is doing, but I understand the rest. I don't *think* that's what I'm looking for, but thank you :)
lucifer
+2  A: 

You could store the field as XML (SQL Server works well with it) if you want something more structured than a simple list. This breaks normalization rules, of course, and complicates your application slightly (having to parse that field when you fetch rows, and having to build it when updating rows), but that's a choice you have to make for yourself.

Dane
Hmmm, thanks for the info. I think, a simple List would be better for me, right now as I'm only new to database stuff and I don't wanna make things too complicated atm.
lucifer
A: 
INSERT PersonValues (PersonID, ValueTypeID, Value)
SELECT 234, 118, '[email protected]'
-- for person 234, insert value type 118 (email address) with said email address

For more information on this type of storage see EAV database.

Emtucifor
A: 

i had a project similar to that and stored the input in a CSV format.

"[email protected]","[email protected]"

then you can use this function to convert the CSV string to an array for manipulation in php

user398651
A: 

Post some of the code you are using to perform the update and we may be able to help you better.

Regards.

xmarcos