[eluser]Jay Logan[/eluser]
I have a page that displays all the athletes for a coach in a drop down menu. The coach then chooses 6 athletes to run a relay event. What I want to do now is remove those 6 athletes from the list so that the coach can choose 6 more athletes without accidentally choosing duplicates. But I just can't seem to get it to work. Could it be all those WHERE statements?
Code:
function get_relay_roster($meet_id, $user_id, $gender, $meet_events_id)
{
$this->db->select('rosters.user_id, rosters.athlete_id, athletes.gender, athletes.fname, athletes.lname');
$this->db->from('rosters');
$this->db->where('rosters.user_id', $user_id);
if ($gender != 'X') {
$this->db->where('athletes.gender', $gender);
}
$this->db->join('athletes', 'athletes.id = rosters.athlete_id');
$get_roster = $this->db->get();
$roster = $get_roster->result_array();
$good_roster[''] = "Choose Athlete";
foreach ($roster as $athlete) {
$this->db->select();
$this->db->from('meet_entries');
$this->db->where('meet_event_id', $meet_events_id);
$this->db->where('athlete_id !=', $athlete['athlete_id']);
$this->db->where('athlete_id_2 !=', $athlete['athlete_id']);
$this->db->where('athlete_id_3 !=', $athlete['athlete_id']);
$this->db->where('athlete_id_4 !=', $athlete['athlete_id']);
$this->db->where('athlete_id_5 !=', $athlete['athlete_id']);
$this->db->where('athlete_id_6 !=', $athlete['athlete_id']);
$athlete_check = $this->db->get();
if ($athlete_check->num_rows() > 0) {
$good_roster[$athlete['athlete_id']] = $athlete['fname'].' '.$athlete['lname'];
}
}
return $good_roster;
}