5 top viewed blog posts of last week

Hi there,

In boonex there is no way to show the best viewed blog posts of the last 7 days ... i think it is always good to present these type of information to your visitors. Just to make them aware what is hot, or not on your site.

$sSQLQuery = "SELECT * FROM `bx_blogs_posts` WHERE `PostDATE` > UNIX_TIMESTAMP(TIMESTAMP(curdate()-7)) ORDER BY `Views` DESC LIMIT 5";
$result = mysql_query($sSQLQuery);
while($row = mysql_fetch_assoc($result)) {
Echo "<table border='0'>
<tbody>
<tr>
<td> <a href='blogs/entry/{$row['PostUri']}'><img src='http://www.YOURDOMAIN.COM/media/images/blog/small_{$row['PostPhoto']}'> </a> </td>
<td> <a href='blogs/entry/{$row['PostUri']}'>{$row['PostUri']}</a> <br><br></td>
</tr>
</tbody>
</table>";
}

 

What does the code do?

It will get blogposts from the last 7 days, sort them on views .. highest on top, lowest bottom .. and select the top 5 posts.

And it will print it out.

Use Deanos Tools to insert a PHP block, and off you go ! :-)

Code is as is .. no warranty, no guarantee .. and absolutely definitely NO SUPPORT ..

Have fun!

Quote · 18 Apr 2011
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.