storing multiple text details in a single table field

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
User avatar
reiqwan
Forum Commoner
Posts: 25
Joined: Fri Jan 07, 2005 2:27 am

storing multiple text details in a single table field

Post 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
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post 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.
Last edited by CoderGoblin on Tue Mar 08, 2005 3:14 am, edited 1 time in total.
User avatar
reiqwan
Forum Commoner
Posts: 25
Joined: Fri Jan 07, 2005 2:27 am

a better explanation

Post 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.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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 ;)
Post Reply