I am creating a tag cloud. I have a table called tags with the number 'id' and row 'tag'.
Each tag "tag" will be a tag like on this site. Imagine a tag called "foo" for this example.
Each line of 'id' will be the identifier of the web pages marked with something - 'foo', in this example.
Thus, any arbitrary string may look like this:
foo | 3 6 16 39 43 58 38 12 55
How to create a function that checks the entire table for the existence of the $ tag, and if it exists, add a space and $ id to the 'id' line for this tag. If the tag does not exist in my table, add the tag and add the identifier.
The code I have (half-php, half-pseudo) is as follows:
if($tag doesnt exist in table)
{
mysql_query("INSERT INTO tags (tag, id) VALUES ('$tag', '$id'");
}
if($tag exists in table)
{
mysql_query("...append somehow... $id . " " WHERE tag = '$tag'");
}
, SQL , . ?