Hi,

This may be hard to describe what I'm trying to do. I have a database table called assignments where there are columns: section, team, and candidate.

For each section, there are 3 teams- 1, 2, 3. The sections are listed alphabetically from A-V. There are 5 candidates per team, so a total of 15 per section. I need to display this for a printer friendly page using dynamic text. For instance:

Section A
Team 1
Candidate_1 Candidate_2 Candidate_3 Candidate_4 Candidate_5

In the database, each candidate has their own row. Modifying the table structure is not an option. Is there any way to pull all candidates from a specific team from different rows to be displayed? Many thanks.

If I understand you right, then maybe a query like:

SELECT candidate FROM tablename WHERE team='$team'

Would pull a list/array of all candidates from a given team.

If I understand you wrong, then it might help if you could post your table schema.

following is the answer for your database pull

just query it

select * from assignments where team =$team and section = $section

Thats it

Regards

I ran a query using this:

SELECT * 
FROM assignment
WHERE assignment.Team = $team and assignment.Section = $section

I kept receiving an error saying "1054 - Unknown column '$team' in 'where clause'

Is there any way to modify this?

$team and $section are php variables.

aka

$team = 1;
$section = 'A';

$query = 'SELECT * 
FROM assignment
WHERE assignment.Team = '.$team.' AND assignment.Section = "'.$section.'"';

can you post your table structure in mysql...
it help to understand and give correct answer to you..

bcoz..how you put your data in column section, team and candidates for 3 teams and for 15 candidates per section is confusing ...

so post your table structure....with example value

This article has been dead for over six months. Start a new discussion instead.