Jump to content

need like button displayed under each blog post


webguync

Recommended Posts

Hi,

 

I am trying to get a facebook like button displayed under each of my blog post, but so far I am just getting three like buttons displayed above the blog post instead of below each one. Below is the function code to display my blog post and also where I cam currently placing the FB like button code.

 

<?php
include 'blogpost.php';

$connection = mysql_connect('localhost', 'username', 'pw') or die ("<p class='error'>Sorry, we were unable to connect to the database server.</p>");
$database = "DBName";
mysql_select_db($database, $connection) or die ("<p class='error'>Sorry, we were unable to connect to the database.</p>");


function GetBlogPosts($inId=null, $inTagId =null)
{
if (!empty($inId))
{
	$query = mysql_query("SELECT * FROM blog_posts WHERE id = " . $inId . " ORDER BY id DESC LIMIT 2"); 
}
else if (!empty($inTagId))
{
	$query = mysql_query("SELECT blog_posts.* FROM blog_post_tags LEFT JOIN (blog_posts) ON (blog_post_tags.postID = blog_posts.id) WHERE blog_post_tags.tagID =" . $tagID . " ORDER BY blog_posts.id DESC");
}
else
{
	$query = mysql_query("SELECT * FROM blog_posts ORDER BY id DESC");
}

$postArray = array();
while ($row = mysql_fetch_assoc($query))
{
	$myPost = new BlogPost($row["id"], $row['title'], $row['post'], $row['postfull'], $row["author_id"], $row['date_posted']);

	array_push($postArray, $myPost);
	echo '<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like show_faces="true" width="450"></fb:like>';//this is where I am currently implementing the FB Like button
}
return $postArray;
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.