This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

Show Star Ratings on Another Page
#11

Hello Norbs
I am having trouble implementing this, what was your code for that latest comments box.
thanks
Peter

Reply
#12

@ppiper
sorry for the late reply, just saw your question
first, I like to place all these add-on codes in a separate php file and callout the code with an "includes" call (this keeps my page HTML clean HTML. Here is the code (make sure you replace the path in line three according to your site
PHP Code:
<?php
define
('IN_COMMENTICS', '1');
require
"/path/to/your/connect.php";


// Start of 'Recent Comments' **********************************************************************************************
$comments = mysql_query("SELECT * FROM `".$mysql_table_prefix."comments` WHERE is_approved = '1' ORDER BY dated DESC LIMIT 4");

while (
$comment = mysql_fetch_array($comments)) {

$page_query = mysql_query("SELECT * FROM `".$mysql_table_prefix."pages` WHERE id = '" . $comment["page_id"] . "'");
$page = mysql_fetch_assoc($page_query);

echo
$comment["name"] . " <br />on <a href='" . $page["url"] . "'>" . $page["reference"] . "</a> <br />at " . date("g:ia (j-F)", strtotime($comment["dated"]));
echo
"<br />- - -<br />";

}
// End of 'Recent Comments' ************************************************************************************************




// Start of 'Most Commented' ***********************************************************************************************
$comments = mysql_query("SELECT page_id, COUNT(page_id) AS total FROM `".$mysql_table_prefix."comments` WHERE is_approved = '1' GROUP BY 'page_id' ORDER BY 'total' DESC LIMIT 3");

while (
$comment = mysql_fetch_assoc($comments)) {

$page_query = mysql_query("SELECT * FROM `".$mysql_table_prefix."pages` WHERE id = '" . $comment["page_id"] . "'");
$page = mysql_fetch_assoc($page_query);

echo
"<p style='font-size:120%; color:#ff0000'>Most commented pages<br /></p>";
echo
"<p />";

echo
"<a href='" . $page["url"] . "'>" . $page["reference"] . "</a> (" . $comment["total"] . ")";
echo
"<br />";

}
// End of 'Most Commented' *************************************************************************************************


echo "<p />";


// Start of 'Top Posters' **************************************************************************************************
$names = mysql_query("SELECT name, COUNT(name) AS total FROM `".$mysql_table_prefix."comments` WHERE is_approved = '1' GROUP BY 'name' ORDER BY 'total' DESC LIMIT 2");

while (
$name = mysql_fetch_assoc($names)) {

echo
$name["name"] . " (" . $name["total"] . ")";
echo
"<br />";

}
// End of 'Top Posters' ****************************************************************************************************
?>
then, in my HTML I call it with
PHP Code:
<?php include($DOCUMENT_ROOT . "/path/to/your/abovecode.php"); ?>
This include-call you can place in anything you like and style it your way! (look through the php code above, I applied my style to it already and you can change this of course to your taste, too)

Hope this helps you
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by DuO-VB
21-Mar-2014, 04:26 PM
Last Post by Steven
01-Feb-2013, 03:48 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)