Jump to content

MySql Query Help


voxxtelum

Recommended Posts

I have a list of links (surveys) in a table that are displayed in a table after a user logs in.  When the user completes a survey, they click on a link on my site that 'completes' the survey and adds it to a separate table which includes the link id and the user id who completed the survey.

 

What I would like to do is when a user looks at the list of links again, they do not see the links they have completed.  I am kind of stuck on this and am running out of ideas.  Does anyone know a way so that I can select all the links from the completed table where the userids match and somehow use that list (or array rather) to query the links table so that they don't show up? I am not looking for specific code, but maybe just a concept or an explanation.

 

I appreciate the help,

Michael

Link to comment
https://forums.phpfreaks.com/topic/93889-mysql-query-help/
Share on other sites

One option: You could restructure your other table to hold all the surveys that have not been completed instead of the ones that have. As soon as a user registers, it adds rows for all surveys and that user. Once they complete the survey the row can simply be deleted.

 

users

-------

user_id

username

etc. whatever you want

 

surveys

-------

survey_id

link

 

incomplete

----------

user_id

survey_id

 

Now all you have to do is write your query to "SELECT * FROM incomplete WHERE user_id='$var'"

I have no idea how your db is structured. I just gave some very basic example db table names and fields.

Link to comment
https://forums.phpfreaks.com/topic/93889-mysql-query-help/#findComment-481147
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.