. Demo at the bottom of
Text Formatted Code
function phpblock_topdownloads()
{
global $_CONF, $_TABLES, $_USER;
//set limit here
$limit = 10;
$poplist = '';
$query = "SELECT f.* FROM {$_TABLES['downloads']} AS f
LEFT JOIN {$_TABLES['downloadcategories']} AS c
ON c.cid = f.cid
";
$query .= COM_getPermSQL('WHERE', 0, 2, 'c' );
$query .= " ORDER BY hits DESC LIMIT {$limit}";
$result = DB_query($query);
$nrows = DB_numRows($result);
if( $nrows > 0 ){
$string = '';
$popular = array();
for( $i = 0; $i < $nrows; $i++ ){
$A = DB_fetchArray( $result );
$string .= $poplist . '';
$popular[] = '<a href="' . $_CONF['site_url']
. '/downloads/index.php?id=' . $A['lid'] . '">' . $A['title']
. '</a> (' . $A['hits'] . ')';
}
if( !empty( $popular )){
$poplist = COM_makeList( $popular, 'list-popular-stories' );
}
}
if ($poplist == '') $poplist = 'Sorry, there is no available data.';
return $poplist;
}