13 Feb, 2003
Show recent comments WITH total comments from that comment author
Posted by: Jennifer In: Scripts
This is from another script request – Show most recent comments AND how many comments that person has made in total. Sort of a combination of this (Show most recent comments) and Girlie's comment leader script.
As shown on Girlie's blog, your connect.php file looks like this:
<?
// name of your database
$database = "database_name";
// connect to database
$db=mysql_connect ("localhost", "database_user", "database_password") or die ('I cannot connect to the database.');
mysql_select_db("$database",$db);
?>
Change the database_user, and the database_password as appropriate.
Then, this is the code that goes on your page: (Change the blog id as appropriate
<?
include ("/path/to/your/connect.php");
?>
<MTComments lastn="5" sort_order="descend">
<p>
<$MTCommentAuthorLink spam_protect="1" $>: <$MTCommentBody remove_html="1" trim_to="100"$>… [<a href="<$MTBlogArchiveURL$><$MTCommentEntryID pad="1"$>.php#<MTCommentID>">go</a>]<br>
(total comments:
<?
$qryCmt = sprintf("SELECT COUNT(*) as count FROM mt_comment WHERE comment_blog_id=1 AND comment_author='%s' AND comment_url='%s' AND comment_email='%s';",htmlentities ("<$MTCommentAuthor encode_php="qq"$>"), "<$MTCommentURL$>", "<$MTCommentEmail$>");
$reslt = mysql_query($qryCmt);
$rw = mysql_fetch_array($reslt );
echo $rw['count'];
?>)
</p>
</MTComments>
(little side note here – if you have a popular name, say like "Jennifer" 😉 – then you'll probably get a slightly inflated number… because it's just checking for the author's name – and it'll count anyone with the same "comment author" name)