Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: bbSync

Yess .. i did it..

Wrote some lines that gets a posts TAGS .. how do i proceed ?

<?php
//
// Fetch a WP posts tags by Kent
//

$db_type = 'mysql';
$db_host = 'localhost';
$db_name = 'xxxxx';
$db_user = 'xxxxx';
$db_pass = 'xxxxx';

// Just picked one, for testing.
$post_id = "6";

@mysql_connect($db_host,$db_user,$db_pass) or die ("Couldnt connect to database!");
@mysql_select_db($db_name) or die ("Couldnt select the requested MySQL table!");

$fetch_post_tags = mysql_query("
SELECT
wp_posts.ID AS POID,
wp_term_relationships.object_id AS RELID,
wp_term_relationships.term_taxonomy_id AS TAXID,
wp_term_taxonomy.taxonomy AS TAXONO,
wp_term_taxonomy.term_id AS TAX_TERID,
wp_terms.term_id AS TERID,
wp_terms.name AS HOT_TAG_NAME
FROM
wp_posts,
wp_term_relationships,
wp_term_taxonomy,
wp_terms
WHERE
(wp_posts.ID = wp_term_relationships.object_id AND wp_posts.ID = '$post_id')
AND
(wp_term_taxonomy.taxonomy = 'post_tag' AND wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)
AND
(wp_term_taxonomy.term_id = wp_terms.term_id)
ORDER BY wp_terms.name ASC
") or die ("Cant fetch data!");

if (mysql_num_rows($fetch_post_tags) > 0)
{
$rowid = 1;

echo "<table border="1">";
echo "<caption>WP posts tags</caption>";
echo "<tr style="background-color: #DDEAD5;">";
echo "<th scope="col">Post ID</th><th scope="col">Tag</th></tr>";

while ($blog = mysql_fetch_array($fetch_post_tags))
{

if ($rowid == 1)
{
echo "<tr><th scope="row">" . $blog['POID'] . "</th>";
}
else
{
echo "<tr><th scope="row">&nbsp;</th>";
}

echo "<td>" . $blog['HOT_TAG_NAME'] . "</td></tr>";

$rowid++;
}

echo "</table>";
}
else
{
echo "Found nothing!";
}
?>

Please dont kill me.. im no pro coder.. :)

Skip to toolbar