Welcome Guest, Not a member yet? Register   Sign In
How to get results from a joined query
#1

[eluser]SteveBluck[/eluser]
Hello everyone.

Please take a look at my query:

Code:
$query = $this->db->query("SELECT a.users_id, a.users_username, GROUP_CONCAT(b.game_id SEPARATOR ' ' )
            FROM users AS a
            JOIN usergames AS b ON a.users_id = b.user_id
            GROUP BY users_id");

Please take a look at my view:

Code:
<?php
      if($query->num_rows() > 0):
      foreach ($query->result() as $row):
      ?>    
      <tr class="row_bg">
        <td class="row_bg center avatar" >&lt;?php echo $row->users_id; ?&gt;</td>
        <td class="row_bg left" ><a href="#">&lt;?php echo $row->users_username; ?&gt;</a></td>
        <td class="row_bg center" >&lt;?php echo $row->game_id; ?&gt;</td>
      </tr>
      &lt;?php
    endforeach;
    endif;
    ?&gt;

Now all works fine apart from the game_id field. I can't seem to get it to show. I think its becasue it comes from the second table I have joined?

Any help to point me in the right direction would be greatly appreciated.


Messages In This Thread
How to get results from a joined query - by El Forum - 04-03-2009, 09:19 AM
How to get results from a joined query - by El Forum - 04-03-2009, 09:28 AM
How to get results from a joined query - by El Forum - 04-03-2009, 09:32 AM
How to get results from a joined query - by El Forum - 04-03-2009, 09:32 AM
How to get results from a joined query - by El Forum - 04-03-2009, 09:35 AM
How to get results from a joined query - by El Forum - 04-03-2009, 09:36 AM
How to get results from a joined query - by El Forum - 04-03-2009, 09:38 AM
How to get results from a joined query - by El Forum - 04-03-2009, 09:43 AM
How to get results from a joined query - by El Forum - 04-03-2009, 09:54 AM
How to get results from a joined query - by El Forum - 04-03-2009, 10:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB