Page 1 of 1

storing multiple text details in a single table field

Posted: Tue Mar 08, 2005 2:48 am
by reiqwan
Hi all;

I have a certain problem regarding storing numerous variables and then being able to extract them from the column.

THe issue is as follows, It's just that I cannot figure out how to send the values to a single field, I need to concatenate the fields into a single string and then be able to seperate them and their particular values, and use them once seperated. I thought about using XML but am not too sure how to do that. If I could get any assistance I'd really appreciate it.

The particular part of the system works as follows:

1) When a user types names into additional text fields (which could be any amount) I need to store them in a single field in a table's column. These values need to have some sort of clear seperator so that when I retrive the info from a mySQL database using php functions, PHP will be able to say that textbox1 value= 'blah and textbox2 value = 'blahblah' and so on and so forth no matter how many field details he adds.

2) I also need to be able to assign multiple values to any of these values.
For instance if a user adds a new text field, and if he tells that text field to have a drop down option the text field needs to store multiple values for that text field.

Many thanks for any assistance with this issue. :D

Posted: Tue Mar 08, 2005 2:53 am
by JayBird
im not sure of your exact problem, but from what i understand, it sounds like you could do with rethinking your DB design

Posted: Tue Mar 08, 2005 3:14 am
by CoderGoblin
I would place the text fields into an an array and use the http://www.php.net/manual/en/function.serialize.php and
http://www.php.net/manual/en/function.unserialize.php commands.

The problem (and solution) you are suggesting would indicate however a DB design problem as has already been mentioned. A separate table may be better holding just the "userid" and the value.

a better explanation

Posted: Tue Mar 08, 2005 3:14 am
by reiqwan
if you have a look at this url I am trying to accomplissh something similiar to this:

Image

If you go to the edit question section you will see what I am trying to accomplish, bascially I need to know how do they store those values nad then re-use them? as they are all dynamic.

If you need more of an explanation I will be more willing to help I have alos spent a numerous amount of hours plaaning nad setting up the most efficient database neccessary to complete something like this.

Posted: Tue Mar 08, 2005 5:35 am
by timvw
consider you have a table additional..

with an additional_id, user_id, name, value...

and see how easy it would be to add more additional fields to your user ;)