13-Apr-2012, 07:11 PM
I'm using commentics for my Testimonial page and was wondering if it's built in some where or if it can be added to where on a page refresh it randomly will show different user testimonials.
<?php
if ($settings->newest_first == "1") {
$sort = "is_sticky DESC, dated DESC"; //newest
} else {
$sort = "is_sticky DESC, dated ASC"; //oldest
}
<?php
if ($settings->newest_first == "1") {
$sort = "is_sticky DESC, RAND()"; //newest
} else {
$sort = "is_sticky DESC, RAND()"; //oldest
}
<?php
public function randomComment() {
$html = '';
$comments = mysqli_query($this->getLink(), "SELECT * FROM `" . $this->getPrefix() . "comments` WHERE `is_approved` = '1' ORDER BY RAND() LIMIT 1");
while ($comment = mysqli_fetch_array($comments)) {
$page_query = mysqli_query($this->getLink(), "SELECT * FROM `" . $this->getPrefix() . "pages` WHERE `id` = '" . $comment["page_id"] . "'");
$page = mysqli_fetch_assoc($page_query);
$html .= $comment["name"] . "<br>";
$html .= "<a href='" . $page["url"] . "?cmtx_perm=" . $comment["id"] . "#cmtx_perm_" . $comment["id"] . "'>" . $page["reference"] . "</a>" . "<br>";
$html .= date("g:ia (jS-M)", strtotime($comment["dated"]));
$html .= $comment["comment"];
}
return $html;
}
<?php
echo $extractor->randomComment();