tapupartforpres Posted August 25, 2008 Share Posted August 25, 2008 Hello people. I search and could not find a solution. Wondering if someone could help. Basically I am creating a form that people can fill to register for an event. They have the option to add a number of guests. Here is my question: 1. In the form if they have guests, how does one post that data to the SQL database so that I know who's guest goes with the main person who filled out the form? Quote Link to comment Share on other sites More sharing options...
joquius Posted August 25, 2008 Share Posted August 25, 2008 Either you keep track of guests in a by giving your table a `guest_of` or `parent` field (whichever is more semantically pleasing for you), or if you only want the guests to exist for each person just add a guests field with comma separated names of the guests (guest1,guest2,guest3). Quote Link to comment Share on other sites More sharing options...
tapupartforpres Posted August 25, 2008 Author Share Posted August 25, 2008 Ok thanks. But one more quick question. How would I code that to relate back to the persons name as the primary poster. Thanks Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 25, 2008 Share Posted August 25, 2008 Either you keep track of guests in a by giving your table a `guest_of` or `parent` field (whichever is more semantically pleasing for you), or if you only want the guests to exist for each person just add a guests field with comma separated names of the guests (guest1,guest2,guest3). No no no, please don't do the CSV. Just make another table and do a join to get the guests for each person. Quote Link to comment Share on other sites More sharing options...
joquius Posted August 25, 2008 Share Posted August 25, 2008 You can use the same table and do a join to the same table. lets say `id`, `parent`, `name` SELECT t1.name as guest_name,t2.name as parent_name FROM table as t1 LEFT JOIN table as t2 ON t1.parent = t2.id WHERE t1.id = 'guests_id' sorry I can't follow up I'm off good luck... Quote Link to comment 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.