I am trying to make 3 table tags system. I have 3 table in mysql:
#Articles#
id
article
content
#Tags#
tag_id
tag (unique)
#tagmap#
id
tag-id
articleid
In my submit php I have:
$tags= explode(',', strtolower($_POST['insert_tags']));
for ($x = 0; $x < count($tags); $x++) {
//Add new tag if not exist
$queryt = "INSERT INTO `tags` (`tag_id`, `tag`) VALUES ('', '$tags[x]')";
$maket = mysql_query($queryt);
//Add the relational Link, now this is not working, beacasue this is only draft
$querytm = "INSERT INTO `tagmap` (`id`, `tagid`, `articleid`) VALUES ('', (SELECT `tag_id` FROM `tags` WHERE tag_id = "$tags[x]"), '$articleid')";
$maketm = mysql_query($querytm);
}
This is not working when I submit new tags to article. Mysql not create new tags in my Tags table.
PS. Sorry for bad english.