Jump to content

Help forming query and maybe a foreach?


BigTime
 Share

Recommended Posts

I would like to do a join I think?  Not sure if Im going about this the right way, and unsure how to format the query.

In one table I have a field called name - I'd like to call all of them - then query another table for any results that exist with that name,
and if so show them all grouped together, and if not, then show the name in RED (or whatever).

This is basically have they submitted or not.

so table1:
name

Select DISTINCT name from table1 ORDER by name ASC

then table2:
id (not the same as the first table)
user (which will match name)
week
description

SELECT * from table2 WHERE (user='$name' AND week='$week')


Then visible results loop looks somthing like:

WEEK 1

NAME1 DESCRIPTION ID
NAME1 DESCRIPTION ID
NAME1 DESCRIPTION ID

NAME2 DESCRIPTION ID
NAME2 DESCRIPTION ID
NAME2 DESCRIPTION ID

NAME3 DESCRIPTION ID
NAME3 DESCRIPTION ID

NAME4 NO SUBMISSION FOUND

NAME5 DESCRIPTION ID
NAME5 DESCRIPTION ID

Do I need to do the first query and then a foreach loop?

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • 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.