Jump to content

Help forming query and maybe a foreach?


BigTime

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
https://forums.phpfreaks.com/topic/281378-help-forming-query-and-maybe-a-foreach/
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.