hello, I need to display contents with their tags, and in same page all the tags of the page contents
the problem is having a limit on contents doesn't work if join tags on them (the number of tags change the number of select contents)
THE TABLES
==========
I have tables :
> contents
> tags
> link_contents_tags (id_tag, id_content)
I need to select contents with tags so for each content I display its tags
I have a pager so I limit the select of contents
the problem is if I make a
> select contents JOIN tags LIMIT xcontents
it won't work because of the y number of tags on each content
and to limit the number of tags is not a solution because it's unkwnown number (it can have no tag or 10)
EXAMPLE
=======
so limit of 3 contents must display :
CONTENTS:
> [B]content_1 [/B]
>> tag1_content1
>> tag2_content1
>> tag3_content1
> [B]content_2[/B]
>> (no tags)
> [B]content_3 [/B]
>> tag1_content3
TAGS:
tag1_content1
tag2_content1
tag3_content1
tag1_content3
but if I set
LIMIT 0, 3
on select contents join tags it'll not display 3 contents but just the first because of the join on x tags
A (not beautiful) SOLUTION
==========================
a solution is to
> select contents with search criterias
> read ids of found contents
> select tags JOIN links WHERE id_content IN (list ids found contents) ORDER BY id_content
> order tags in an array by content_id : arTags[content_id]=array rows tags
> display all contents, for each content display tags from tags array if exist
> display next all contents from this page
it'll work with contents pager and unknown tags number by content
but it seems a little rude :)
two requests (can be ok) but a few loops on contents that I don't like
have any idea to simplify it?
I don't like to make ugly code :)
think's in advance