Well I made a tag system and it all works. Well when someone posts a blog they enter tags and each tag needs to go in as 1 tag each field. So if someone types "This is my tags" And in the database it needs to be like this (And sorry if the example isnt good) ID|Tag ------- 1 |This 2 |is 3 |my 4 |tags And I know before inserting to use array_unique to remove duplicates since I dont need duplicates. But I dont know how to get each tag in its own special field in the database
$array = explode(" ",$tags); foreach($array as $key => $value) { mysql_query("INSERT INTO tags_table VALUES (NULL,'".$value."') WHERE '".$value."' NOT IN (SELECT Tag FROM tags_table WHERE Tag = '".$value."')"); } PHP:
you can try to set "id" and "tag" fields are "key", so you CAN NOT insert duplicate data to that table
you should use explode first with spaces as suggested by tvoodoo..however better approach would be ask your users to enter tag line by line and explode using php_EOL