I have a simple contest sign-up web form. Each contestant can check a box to be eligible to win one of 20 prizes. Upon submitting a form, a row is created in the "contestants" table. For each prize they have checked, a row in the "entries" table is created.
I am trying to make a "results" page that lists all prize names, and below each prize name all of the contestants who want to be eligible to win that prize. Prizes for which no contestants have signed up will have no contestants listed below their name.
How do I write an efficient MySQL query to easily produce such a page (using PHP)?
Tables
contestants
- id
- name
- address
- city
- state
entries
- id
- contestant_id
- prize_id
prizes
- id
- name
- description