How's it going guys, So i've just moved from Kunana over to EasyDiscuss loving the ease that was. to migrate thanks for making my life easier.
Any how, now that i've got the Tagging system in place i'm looking to add my discussions to each relevent Tag, i've got over 2k discussions and it would be a seirous waste of time for me if i need to go into each discussion one by one to add the tag.
Make any sence O.o
Best
Quick edit: i manged by doing this i figured out the link between the catergorys and tags and then mappend them
//Query Gets Posts IDs where the posts Categroy ID and Category ID are the same
$PostID = "SELECT at6ln_discuss_posts.id
FROM at6ln_discuss_posts
INNER JOIN at6ln_discuss_category ON at6ln_discuss_posts.category_id = at6ln_discuss_category.id";
$resultPostID= $conn->query($PostID);
//Query Gets catergory ID where the Categroy and Tag Alias is the same
$CategoryID = "SELECT at6ln_discuss_category.id
FROM at6ln_discuss_category
INNER JOIN at6ln_discuss_tags ON at6ln_discuss_category.alias = at6ln_discuss_tags.alias";
$resultCategoryID= $conn->query($CategoryID);
//Query Gets Posts catergory ID where the Categroy and Tag Alias is the same
$PostsCategoryID = "SELECT at6ln_discuss_posts.category_id, at6ln_discuss_category.alias
FROM at6ln_discuss_posts, at6ln_discuss_category
WHERE (at6ln_discuss_posts.category_id = at6ln_discuss_category.id)";
$resultPostsCategoryID= $conn->query($PostsCategoryID);
//Query Gets catergory Alais where the Categroy and Tag Alias is the same
$PostsCategoryAlias = "SELECT at6ln_discuss_category.alias
FROM at6ln_discuss_category
INNER JOIN at6ln_discuss_tags ON at6ln_discuss_category.alias = at6ln_discuss_tags.alias";
$resultPostsCategoryAlias= $conn->query($PostsCategoryAlias);
$sql = 'INSERT INTO at6ln_discuss_posts_tags (post_id,tag_id) VALUES (?,?)';
$stmt = $conn->prepare($sql);
if ($resultTagID->num_rows > 0) {
echo "<table>";
echo "<tr>";
echo "<th> Post ID </th>";
echo "<th> Tag ID </th>";
echo "<th> Post Catergory ID </th>";
echo "</tr>";
// output data of each row
while ($posts = $resultPostID->fetch_assoc()) {
// output data of each row
$category = $resultCategoryID->fetch_assoc();
$postscatID = $resultPostsCategoryID->fetch_assoc();
// output data of each row
$idcategory = $category["id"];
$idposts = $posts["id"];
$idpostcat = $postscatID["category_id"];
if ($idpostcat >= 5){
switch($idpostcat) {
case 5:
$TagID = 10;
break;
case 7:
$TagID = 12;
break;
case 13:
$TagID = 17;
break;
case 14:
$TagID = 18;
break;
case 15:
$TagID = 19;
break;
case 16:
$TagID = 20;
break;
case 27:
$TagID = 29;
break;
case 28:
$TagID = 30;
break;
case 30:
$TagID = 32;
break;
case 34:
$TagID = 35;
break;
case 35:
$TagID = 36;
break;
case 37:
$TagID = 38;
break;
case 38:
$TagID = 39;
break;
case 49:
$TagID = 47;
break;
case 50:
$TagID = 48;
break;
case 52:
$TagID = 50;
break;
case 53:
$TagID = 51;
break;
case 55:
$TagID = 46;
break;
}
$stmt->bind_param('ii', $idposts, $TagID);
$stmt->execute();
echo "<tr>";
echo "<td>" . $idposts . "</td>";
echo "<td>" . $TagID . "</td>";
echo "<td>" . $idpostcat . "</td>";
echo "</tr>";
}
}