Settig Up a survey system in PHP and mysql.. help needed

Posted on 2010-04-10
Medium Priority
Last Modified: 2013-12-13
I have a site where I survey members from time to time. I want members of certain lists to be directed to a survey page/file. The problem is I need to make sure the survey they are directed to is the one related to their lists and is currently active.

I've set up a survey table where I can add the names of the surveys and file names and even paths and the list Id numbers they are associated with I call that tables Surveys1

The surveys themselves create their own tables and I have code in them that cheks for multiple member entries in the survey tables so I'm fine there. No one will be able to add the form results more than once.

So what I need is a method to show members the right surveys when they log in and click on the survey page. I'm thinking the best way would be to check the database for active surveys for lists  they are members of. The pages already gets their list ID number so its already available as a variable. I could run that against the surveys table and see if there is an active survey and even get the survey file name and location but how would I write that?

How would I direct them to the file name? Would i create a variable out of the survey names or file names of file paths or something? Can a variable be passed in a link?
What should I put in the surveys table to accomplish this?

Thanks for all the help..

Question by:new_to_php
LVL 11

Expert Comment

by:Goodangel Matope
ID: 30372989
You could create a table called "member_lists" in your database which contains the member's id, and the list the are a member of. If  for example, a member with ID 5 is a member of two lists, one with ID 6 and one with ID 7, then you would have two entries in your table, both with ID 5 as the member_id, one having 6 representing the one list and 7 as the list_ID.

When a user clicks on the survey link, you then bring up the survey for the list with the list_id in the member_lists table, by bringing up active survey for the selected list_id

I dont know if this makes sense to you, but it does to me :-)

Accepted Solution

new_to_php earned 0 total points
ID: 30417902
I have a many to many table already..

How it works is member go to a specific list info page.. it checks to see if they are a member already etc..  what I need is the best way to serve the surveys

I was thinking of querying the survey1 table finding the active list where the list id's match (I already know the member is a member of that list because in order toget this far he'd have to be.

If there is a survey that matches I was think to take the name of the survey and somehoe hand it to an url such as:


I check in the beginning of each survey for duplicate DB entries so II'm not worried about direct accesss etc.

Should I create a variable out of the survey names? Should I store them survey url in the db? Should I simply haven a url that handles the survey variable in the handler page that directs them to the survey?

I'm new to PHP and not sure how to best handle this..



Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question