TinyPortal

Development => Block Codes => Topic started by: wilsy on January 04, 2008, 01:25:38 PM

Title: Stats "Statement" Block
Post by: wilsy on January 04, 2008, 01:25:38 PM
Hi all,

I have a statement in a block regarding some of the site statistics, this is the code: -

global $context, $settings, $options, $scripturl, $txt, $db_prefix, $modSettings;

$result = db_query("
SELECT COUNT(*) AS totalMembers, gender
FROM {$db_prefix}members
GROUP BY gender", __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($result))
$gender[$row['gender']] = $row['totalMembers'];

isset($gender[0]) ? null : $gender[0] = 0;
isset($gender[1]) ? null : $gender[1] = 0;
isset($gender[2]) ? null : $gender[2] = 0;

$result = db_query("
SELECT COUNT(ID_BOARD)
FROM {$db_prefix}boards", __FILE__, __LINE__);
list ($modSettings['boards']) = mysql_fetch_row($result);
mysql_free_result($result);

$result = db_query("
SELECT COUNT(ID_CAT)
FROM {$db_prefix}categories", __FILE__, __LINE__);
list ($modSettings['categories']) = mysql_fetch_row($result);
mysql_free_result($result);

       if(isset($context['TPortal']['userbox']['stats']))


echo '<img src="/ultprof/blog.png"/> There are ',$modSettings['totalMessages'],' messages and ',$modSettings['totalTopics'],' topics in the discussion forums. Out of ', $modSettings['totalMembers'],' members at ', $context['forum_name'],' - ';
echo "
$gender[1] are male,
$gender[2] are female and
$gender[0] are still undecided
";
echo ' - our latest member is <a href="', $scripturl, '?action=profile;u=', $modSettings['latestMember'], '"><b>', $modSettings['latestRealName'],'.</b></a><br /><br />';
echo '<img src="/ultprof/buddy.png"/> Most online at once was ',$modSettings['mostOnline'],' visitors ('.timeformat($modSettings['mostDate']).').';



You will need to replace the image paths with your own, e.g. <img src="/ultprof/blog.png"/>

You can see it in action as a guest on the front page of my website (at the bottom), the link is in my signature.

Almost all of the above code has been taken from blocks already posted at TP - credit must go to the original authors  8)

Regards,

Wilsy.
Title: Re: Stats "Statement" Block
Post by: wilsy on January 05, 2008, 09:29:25 AM
Screenshot added, you wil need to be logged in to see it)  :)

(https://www.tinyportal.net/index.php?action=dlattach;topic=21154.0;attach=13367;image)