TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 790
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 651
  • Total: 652
  • tino

Stats "Statement" Block

Started by wilsy, January 04, 2008, 01:25:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wilsy

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.

wilsy

Screenshot added, you wil need to be logged in to see it)  :)


This website is proudly hosted on Crocweb Cloud Website Hosting.