Image

Imageelvishly wrote in Imagephp

PHP/MySQL -- Tags and tag clouds.

Hi!

I'm trying to set my site up so I have a tag cloud (which I have working finely) and the ability to "click" these tags to take it to a page which would list all pages/relevant "rows" that have the tag...in the tags.

I have my database set up so there are three separate tables with a tag column (updates --> updateTags; stories --> storyTags; archives --> archiveTags). The tag columns consist of, essentially, "tag1, tag2, tag3, tag4" or "tag4, tag7, tag2" et cetera.

I have selecting the tags for the tag cloud down by using UNION to merge all three tag columns together and doing it that way. However, I'm struggling with selecting the rows from all three tables with a specific tag.

My code is:

$query = "SELECT updateTags, updateName FROM updates
WHERE `updateTags` LIKE '%".escapestring($_GET['tag'])."%'";


Which is fine for just finding the relevant rows in the table updates. How would I code it so it would also find the relevant details for the two other tables? I tried UNION again and using "as" but it, ah, didn't quite work. x)

Thanks!