Apophenia Overload Posted January 14, 2011 Share Posted January 14, 2011 Say I have a form like this (stored on the Main table): Name ___ Address ___ Phone # ____ + If I click on +, another field pops up Name ___ Address ___ Phone # ____ Phone # ____ + If you click on +, another field is generated, and so on. I think I have a good idea how to get this to display on the frontend (I'm using CodeIgniter, any tips on that would be appreciated as well). However, I'm not too clear as to how to store this- how would I store Phone# if there are multiple instances of it? It is a list, after all. Would I have to create a table just for Phone #? And if so, how should I join it with the Main table? Quote Link to comment https://forums.phpfreaks.com/topic/224406-storing-values-in-a-form-that-allows-a-field-to-be-generated-multiple-times/ Share on other sites More sharing options...
yamipoli Posted January 14, 2011 Share Posted January 14, 2011 You could perhaps store the phone numbers as a comma-separated string, like on the phone column if someone had input two phone numbers, you might see 111-222-3333,111-333-444 and use whatever language you choose to split by the comma. otherwise, a table for telephone numbers would work. you could make a table and link them via account names/id numbers/whatever. simple joining syntax might be select * from `users`, `telephone_numbers` where `user_id` = `telephone_user_id` ? Quote Link to comment https://forums.phpfreaks.com/topic/224406-storing-values-in-a-form-that-allows-a-field-to-be-generated-multiple-times/#findComment-1159273 Share on other sites More sharing options...
Apophenia Overload Posted January 14, 2011 Author Share Posted January 14, 2011 To be honest, it's a bit more complex than numbers. My table actually has a secondary field associated with Phone #. So it'd be like this: Phone # _______ (+) Ext. _______ Upon clicking (+), Phone # _______ Ext. _______ Phone # _______ (+) Ext. _______ I'm trying to avoid doing anything fancy to make each Phone # to be paired with the Ext., but I'm not sure if it's possible. For now, I'm not going to combine each pair into a singleton. edit: Hmm, I suppose I could have a three-table approach. One Main table, one table for Phone #, and one for Extensions. The phone # and ext. would be easy enough to match- if there was a number without an ext., I'd just force the frontend to send some sort of symbol so it wouldn't ever be blank. However, having 3 tables seems a bit clunky... Quote Link to comment https://forums.phpfreaks.com/topic/224406-storing-values-in-a-form-that-allows-a-field-to-be-generated-multiple-times/#findComment-1159278 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.