Top 5 most popular games?
On my site (aimed at PS3 gamers), users can select the 3 games they're currently playing. I will then work out which games are the most popular, and list the top 5 based on active users.

I have 3 columns in my users table called game1_id, game2_id and game3_id. These values are relational to the id column in another table called game, which contains all of the information on the games such as it's title.

How would I go about tallying up these totals and returning the top 5 most active games?

Here is my model function thus far:

	function get_5_popular_games()
	
	{
	
		$this->db->select('user.game1_id, user.game2_id, user.game3_id');
		$this->db->from('user');
		$query = $this->db->get();
		
		if ($query->num_rows() > 0)
		
		{
		
			return $query->result();
		
		}
	
	}

I assume I need to somehow tally up how many times a games id is found in any of the three columns (game1_id, game2_id, game3_id), but I'm not entirely sure how to go about it?

Thanks!

Top 5 most popular games?
===

On my site (aimed at PS3 gamers), users can select the 3 games they're currently playing. I will then work out which games are the most popular, and list the top 5 based on active users.

I have 3 columns in my users table called game1_id, game2_id and game3_id. These values are relational to the id column in another table called game, which contains all of the information on the games such as it's title.

How would I go about tallying up these totals and returning the top 5 most active games?

Here is my model function thus far:

	function get_5_popular_games()
	
	{
	
		$this->db->select('user.game1_id, user.game2_id, user.game3_id');
		$this->db->from('user');
		$query = $this->db->get();
		
		if ($query->num_rows() > 0)
		
		{
		
			return $query->result();
		
		}
	
	}

I assume I need to somehow tally up how many times a games id is found in any of the three columns (game1_id, game2_id, game3_id), but I'm not entirely sure how to go about it?

Thanks!
