codeigniter forum join problem
Hello all i have a problem with my forum
my forum have a categori in that i show the threads thats created on that categori, and i show the user profile picture, the user name who created and the user name who last replay on the topic.
my problem is that if there is 2 comment on a topic it will show the topic 2 times in the categori like this: http://d.pr/QxAY
and my code is this: traad = thread kommentare = comments
$this->db->select('*,users.profile_picture as profil_billed, forum_traad.id as traad_id,
forum_kommentare.brugernavn as comment_username');
$this->db->from('forum_traad');
$this->db->join('users', 'forum_traad.brugernavn = users.userna开发者_开发技巧me');
$this->db->join('forum_kommentare', 'forum_traad.id = forum_kommentare.fk_forum_traad', 'left');
$this->db->where('forum_traad.fk_forum_kategori', $id);
$this->db->order_by("forum_traad.id", "DESC");
I think your problem will be solved if you use MYSQL's GROUP_CONCAT function on the comments column of your result. By doing this you will get topic only once and the multiple comments to that topic in the comma seperated format which you can seperate in your code later.
After trying this Let Me Know.
精彩评论