My database schema for adding tags is the same as this question...
My question is how do I relate each tag with the current thread, so far I have done this:
$sql = "INSERT INTO thread (title, content, author_id)
VALUES ('$safe_title', '$safe_html_content', '$user_id')";
$insert_thread = insert_Query($sql, $link);
# get the thread id:
$thread_id = mysqli_insert_id($link);
# insert the tags:
foreach ($tags as $tag)
{
insert_Query("INSERT INTO tags (tag)
VALUES ('$tag')", $link);
}
# connect tags to thread:
$sql = "INSERT INTO thread_tags (thread_id, tag_id)
VALUES ('$thread_id', )"; ## what to do here?
I want to know how I can fill in the ItemTag table (thread_tags in my case)... I can get the id of the current thread as shown in the $thread_id var, but how do I get the id of each tag and associate it with this thread?
Thank you.