| | |
Selecting same column multiple times
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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.
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.
•
•
Join Date: Jul 2008
Posts: 14
Reputation:
Solved Threads: 3
If I understand you right, then maybe a query like:
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.
PHP Syntax (Toggle Plain Text)
SELECT candidate FROM tablename WHERE team='$team'
If I understand you wrong, then it might help if you could post your table schema.
Last edited by mike_g; Dec 23rd, 2008 at 3:42 pm.
•
•
Join Date: May 2008
Posts: 5
Reputation:
Solved Threads: 0
following is the answer for your database pull
just query it
Thats it
Regards
just query it
PHP Syntax (Toggle Plain Text)
select * from assignments where team =$team and section = $section
Regards
Last edited by peter_budo; Dec 29th, 2008 at 5:38 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
I ran a query using this:
I kept receiving an error saying "1054 - Unknown column '$team' in 'where clause'
Is there any way to modify this?
PHP Syntax (Toggle Plain Text)
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?
•
•
Join Date: Jul 2008
Posts: 149
Reputation:
Solved Threads: 25
$team and $section are php variables.
aka
aka
PHP Syntax (Toggle Plain Text)
$team = 1; $section = 'A'; $query = 'SELECT * FROM assignment WHERE assignment.Team = '.$team.' AND assignment.Section = "'.$section.'"';
Last edited by mschroeder; Dec 24th, 2008 at 1:17 pm.
•
•
Join Date: Apr 2008
Posts: 297
Reputation:
Solved Threads: 11
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
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
Last edited by Aamit; Dec 25th, 2008 at 3:12 am.
![]() |
Similar Threads
- memory management in wndows 2000 (Windows NT / 2000 / XP)
Other Threads in the PHP Forum
- Previous Thread: two submit buttons calling 2 different functions - PHP
- Next Thread: Count page views??
Views: 524 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date datepart directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link list login loop mail menu methods mlm mod_rewrite multiple mysql oop parse password paypal pdf php problem query radio random recursion regex remote script search select seo server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web webdesign xml youtube





