Hi
I've seen this on a few joomla based sites where you get something like:
Total Members 233234
New This Month:123
New This Week: 45
New Today: 8
Can someone make something similar for inclusion with the stats box?
Aku
i would love to have this block - much credit to the one who creates the code :coolsmiley:
This is separate code, but you could put it wherever you wanted:
global $db_prefix,$modSettings;
$today = strtotime("24 hours ago");
date('j') == 1 ? $thismonth = $today : $thismonth = strtotime(date('F') . ' 1');
date('l') == 'Sunday' ? $thisweek = $today : $thisweek = strtotime('last Sunday');
date('M') == 'January' ? $thisyear = $thismonth : $thisyear = strtotime('January 1');
$query = db_query("SELECT
COUNT(dateRegistered > $thisyear OR NULL) as year,
COUNT(dateRegistered > $thismonth OR NULL) as month,
COUNT(dateRegistered > $thisweek OR NULL) as week,
COUNT(dateRegistered > $today OR NULL) as today
FROM {$db_prefix}members
WHERE is_activated = 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);
settype($row['today'], "integer");
settype($row['week'], "integer");
settype($row['month'], "integer");
echo 'Total Members: ', $modSettings['totalMembers'],'<br />';
echo 'New This Month: ', $row['month'],'<br />';
echo 'New This Week: ', $row['week'],'<br />';
echo 'New Today: ', $row['today'];
It also returns the number for the year. I figured I'd go ahead and get the data just in case someone might want it.
Thanks
ill try it out asap :D
no workie
gving stats:
Total Members: 1039
New This Month: 0
New This Week: 0
New Today: 0
and today 3 people joined up and this week according to my approximation about 5 to 7 people joined up
and for the moth the stats show: 19 people joined
but it shows zero for all
:sigh:
Back to the drawing board, I guess. :)
dont worry atleast u got 88.543% of the code working (according to my calculations) :up:
Let's try it again. I left out a little minor detail. ::)
Instead of
db_query("SELECT
use
$query = db_query("SELECT
That should do it. I'll edit the original code.
now it is working 98.945%
the reason i say this is cos today someone joined my forum in front of me (about 2 hours back) and made a lotta posts and requested dance songs on the online radio as well lol
but it shows:
Total Members: 1039
New This Month: 18
New This Week: 7
New Today: 0
What time is it where you are? Or, better still, what time is it where your server is? The day is the calendar day as defined by your server. So, if it's after midnight wherever your server is, you won't get anybody who registered before midnight. We could change it to "within the last 24 hours."
nope dosent seem to be the issue
i just used opera to register a new member
and the counter for tody still at 0
but week and month progressed forward by 1
Is the account activated?
The only thing you can do is change
$today = strtotime("today");
to
$today = strtotime("24 hours ago");
which will give you the number of registrations within a rolling 24-hour period. I know that the strtotime("today") code gives the Unix time for midnight on the current calendar day.
Nice...me likey...I might add this to the boardindex!! WOOT WOOT!
[Nice idea for a mod]
holy cazambo gubu gubu!!! IT WORKS!!!
(whatever tht means - i just made it up!)
Total Members: 1040
New This Month: 19
New This Week: 8
New Today: 5
:D Thanks so much!! ur the best!! :D
LMAO....
You get alot of members....daaaamn..
Good it works now.
Great work Just Plain.
I like the idea/concept. *Gives Thumbs Up*
:2funny:
What did you do, aku? Did you change it to 24 hours?
Glad it worked for you. ;D
Glad you like it too, Jpg.
It worked out nicely because I just really understood something new (to me) in mysql and it was what made this work. It's great when I'm able to apply something I've just learned.
yes the 24 hour one worked :D
thanks again :D
(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi26.photobucket.com%2Falbums%2Fc147%2Fjbrowning%2Fchewy.gif&hash=4796439a333fc2cbf1f348b912f4e82ad440b08c) (http://path-to-peace.net/forum)<<<-- Demo click the dude
and then look in left bar at the bottom near the stats
i tweaked the code a little and placed it within my stats box, but i cannot get it to '
';
look at the picture and right after the latest members name you will see what i mean where it says Kalo then new this month. i have placed the break code in several places but it wont return the next line. any suggestions? thanks
here is my template code with the added above code
// members stats
echo '
<img src="'.$settings['images_url'].'/icons/members.gif" style="margin: 0;" align="bottom" alt="" />
<a href="'.$scripturl.'?action=mlist"><b>'.$txt[19].'</b></a>
<br />'.$bullet.$txt[488].': ' , isset($modSettings['memberCount']) ? $modSettings['memberCount'] : $modSettings['totalMembers'] , '
<br />'.$bullet.$txt['tp-latest']. ': <a href="', $scripturl, '?action=profile;u=', $modSettings['latestMember'], '"><b>', $modSettings['latestRealName'], '</b></a>';
if(isset($context['TPortal']['userbox']['stats_all']))
global $db_prefix,$modSettings;
$today = strtotime("today");
date('j') == 1 ? $thismonth = $today : $thismonth = strtotime(date('F') . ' 1');
date('l') == 'Sunday' ? $thisweek = $today : $thisweek = strtotime('last Sunday');
date('M') == 'January' ? $thisyear = $thismonth : $thisyear = strtotime('January 1');
$query = db_query("SELECT
COUNT(dateRegistered > $thisyear OR NULL) as year,
COUNT(dateRegistered > $thismonth OR NULL) as month,
COUNT(dateRegistered > $thisweek OR NULL) as week,
COUNT(dateRegistered > $today OR NULL) as today
FROM {$db_prefix}members
WHERE is_activated = 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);
settype($row['today'], "integer");
settype($row['week'], "integer");
settype($row['month'], "integer");
echo 'New This Month: ', $row['month'],'<br />';
echo 'New This Week: ', $row['week'],'<br />';
echo 'New Today: ', $row['today'];
echo '<br />New This Month: ', $row['month'],'<br />';
That should do it.
that did the trick, thanks ;D just one more little thing if you don't mind. i have been trying to add bullets in front of the stats to match the rest of the stats box. i have gotten the bullets to show up in a couple different places, but not in the front of the text, and i have gotten parse errors at least 10 times. :-\ where would i place the $bullet to make it show before the stats text? thanks again.
You can try:
echo '<br />',$bullet,'New This Month: ', $row['month'],'<br />';
echo $bullet,'New This Week: ', $row['week'],'<br />';
echo $bullet,'New Today: ', $row['today'];
You shouldn't get a parse error with those.
Glad to help. :)
worked like a charm. i was so close and had it in the right spot a couple times but was using $bullet. instead of $bullet, only because i saw in other parts of the template the period was used with $bullet
thank you! it looks like it belongs now. :)
You should be able to use the period or the comma, although the comma supposedly makes it go faster. You may have missed out on a single quote somewhere. Or maybe the gremlins were acting up. ;)
yes the logic behind the comm and period is as follows:
the . is like a pebble so it can cause your php to slow down
however the , is like a slide so the php zooms by on it
:up:
i have no doubts i had something wrong, but thats why i come here to lean on you guys. ;) i try it myself for awhile and when the butchering doesn't work i count on the help here to get the ship righted. when it comes to hardware i do just fine, building and working on pcs, but when it comes to codes i am a drooling gurgling infant that just feels totally helpless sometimes. ;D between bloc, ichbin, akulion, and others i have yet to not resolve an issue no matter how simple the question or hard the answer and the help comes extremely fast. :up: :up:
i was just joking about the comma and period :P lol
Quotethe . is like a pebble so it can cause your php to slow down
:2funny:
Well, that's a way to remember it, I guess. ;D
QuoteI try it myself for awhile and when the butchering doesn't work i count on the help here to get the ship righted
That's the way to do it. I love helping people like you. And when I have problems with hardware, I'll know just who to ask. ;)
ok my text is real small with this block code, check it http://carnage.sector-wars.com/oforums/index.php?action=forum (http://carnage.sector-wars.com/oforums/index.php?action=forum)
how do i make the text like my other text? or change the size
Quote from: MeRcChRiS on October 17, 2006, 11:59:31 PM
http://carnage.sector-wars.com/oforums/index.php?action=forum (http://carnage.sector-wars.com/oforums/index.php?action=forum)
your link is incorrect
You sure? i just clicked it and it took me there O.o
Anyways, try this one i guess
http://carnage.sector-wars.com/oforums/index.php? (http://carnage.sector-wars.com/oforums/index.php?)
u could try this:
echo '<font size="12">New This Month: ', $row['month'],'<br />';
echo 'New This Week: ', $row['week'],'<br />';
echo 'New Today: ', $row['today'],'</font>';
Quote from: MeRcChRiS on October 17, 2006, 11:59:31 PM
ok my text is real small with this block code, check it http://carnage.sector-wars.com/oforums/index.php?action=forum (http://carnage.sector-wars.com/oforums/index.php?action=forum)
how do i make the text like my other text? or change the size
Get rid of the <h6> tags you put in there. ;)
can you add the
Total Members:
in that last code also
Thanx for the code... It works well on my forum (http://ausaid-students.co.nr)
cheers!
This works pretty good on my site too :up:
Quote from: rbh on October 10, 2006, 04:01:36 AM
i tweaked the code a little and placed it within my stats box, but i cannot get it to '
';
look at the picture and right after the latest members name you will see what i mean where it says Kalo then new this month. i have placed the break code in several places but it wont return the next line. any suggestions? thanks
here is my template code with the added above code
// members stats
echo '
<img src="'.$settings['images_url'].'/icons/members.gif" style="margin: 0;" align="bottom" alt="" />
<a href="'.$scripturl.'?action=mlist"><b>'.$txt[19].'</b></a>
<br />'.$bullet.$txt[488].': ' , isset($modSettings['memberCount']) ? $modSettings['memberCount'] : $modSettings['totalMembers'] , '
<br />'.$bullet.$txt['tp-latest']. ': <a href="', $scripturl, '?action=profile;u=', $modSettings['latestMember'], '"><b>', $modSettings['latestRealName'], '</b></a>';
if(isset($context['TPortal']['userbox']['stats_all']))
global $db_prefix,$modSettings;
$today = strtotime("today");
date('j') == 1 ? $thismonth = $today : $thismonth = strtotime(date('F') . ' 1');
date('l') == 'Sunday' ? $thisweek = $today : $thisweek = strtotime('last Sunday');
date('M') == 'January' ? $thisyear = $thismonth : $thisyear = strtotime('January 1');
$query = db_query("SELECT
COUNT(dateRegistered > $thisyear OR NULL) as year,
COUNT(dateRegistered > $thismonth OR NULL) as month,
COUNT(dateRegistered > $thisweek OR NULL) as week,
COUNT(dateRegistered > $today OR NULL) as today
FROM {$db_prefix}members
WHERE is_activated = 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);
settype($row['today'], "integer");
settype($row['week'], "integer");
settype($row['month'], "integer");
echo 'New This Month: ', $row['month'],'<br />';
echo 'New This Week: ', $row['week'],'<br />';
echo 'New Today: ', $row['today'];
I would also like to get it working this way. Can you tell me which files you edited? I thought it might be in Stats.php but couldnt find where that code belongs. Cheers! :)
Quote from: JPDeni on October 09, 2006, 09:58:37 PM
This is separate code, but you could put it wherever you wanted:
global $db_prefix,$modSettings;
$today = strtotime("today");
date('j') == 1 ? $thismonth = $today : $thismonth = strtotime(date('F') . ' 1');
date('l') == 'Sunday' ? $thisweek = $today : $thisweek = strtotime('last Sunday');
date('M') == 'January' ? $thisyear = $thismonth : $thisyear = strtotime('January 1');
$query = db_query("SELECT
COUNT(dateRegistered > $thisyear OR NULL) as year,
COUNT(dateRegistered > $thismonth OR NULL) as month,
COUNT(dateRegistered > $thisweek OR NULL) as week,
COUNT(dateRegistered > $today OR NULL) as today
FROM {$db_prefix}members
WHERE is_activated = 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);
settype($row['today'], "integer");
settype($row['week'], "integer");
settype($row['month'], "integer");
echo 'Total Members: ', $modSettings['totalMembers'],'<br />';
echo 'New This Month: ', $row['month'],'<br />';
echo 'New This Week: ', $row['week'],'<br />';
echo 'New Today: ', $row['today'];
It also returns the number for the year. I figured I'd go ahead and get the data just in case someone might want it.
where must i put it....
It depends on where you want it. If you want it in a block, put it in a php block.
Which code is correct to use?
Use the first code in the topic. I've made changes to it as errors were found. If you have a problem, post your problem and we'll get it worked out.
Alright, I have one tiny problem's. I have 24 new member's join the forum this month.
The code saying I have 23 new member's join this month.
New this week. I have two new this week and the code saying i have one new this week.
Tell me which days this week you've had new members join. Was it Sunday and Monday or two on Monday? How about this month? Did you have one on the first day of the month?
This month i have 24 member's join the forum. I have two new member's join this week. I think one on money and anther last night or so.
I need to know whether you had one on the first of the month or one on Sunday. I need specific information in order to be able to trouble-shoot the code.
Last tueday they join the forum..
Oh. Well last Tuesday isn't part of this week. "This week" starts on Sunday. Or did you want "within the past 7 days" instead of "this week"? They mean two very different things.
I'm sorry, I didn't know that. Yes, I want it then 7 week day's
Sorry. I didn't see your post before. You can change the time frames to match what you want. The original code is
date('j') == 1 ? $thismonth = $today : $thismonth = strtotime(date('F') . ' 1');
date('l') == 'Sunday' ? $thisweek = $today : $thisweek = strtotime('last Sunday');
date('M') == 'January' ? $thisyear = $thismonth : $thisyear = strtotime('January 1');
You can change it to
$thismonth = strtotime("30 days ago");
$thisweek = strtotime("7 days ago");
$thisyear = strtotime("1 year ago");
I was wondering if I added this to the stats box where do I add it in there is no place to add code, just the title and then what you want showing.
You have to add the code manually. TPortalBlocks.template.php is where thats at.
You can add that to the statue block?
What code would I be looking for to replace? or add to?
That statsbox is defined in TPortalBlocks.template.php, function TPortal_statsbox.
What code are we looking for in that file? Before we add that code to the status box?
Nice Code !! :) Just have some problems with the things I've added:
/*
1. Gaeste bekommen ForumStats angezeigt.
2. Mitglieder die Begruessungsbox
3. Admins die NeuRegistrierungen
*/
global $context,$db_prefix,$modSettings;
if ($context['user']['is_guest'])
TPortal_statsbox();
else if ($context['user']['is_logged'] && !$context['user']['is_admin'])
TPortal_userbox();
else if ($context['user']['is_admin'])
$today = strtotime("24 hours ago");
date('j') == 1 ? $thismonth = $today : $thismonth = strtotime(date('F') . ' 1');
date('l') == 'Sunday' ? $thisweek = $today : $thisweek = strtotime('last Sunday');
date('M') == 'January' ? $thisyear = $thismonth : $thisyear = strtotime('January 1');
$query = db_query("SELECT
COUNT(dateRegistered > $thisyear OR NULL) as year,
COUNT(dateRegistered > $thismonth OR NULL) as month,
COUNT(dateRegistered > $thisweek OR NULL) as week,
COUNT(dateRegistered > $today OR NULL) as today
FROM {$db_prefix}members
WHERE is_activated = 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);
settype($row['today'], "integer");
settype($row['week'], "integer");
settype($row['month'], "integer");
echo '<div style="text-align: center;"><span
style="font-weight: bold; text-decoration: underline;">Admin-Info</span></div>';
echo 'Mitglieder: ', $modSettings['totalMembers'],'<br />';
echo 'Neue/Monat: ', $row['month'],'<br />';
echo 'Neue/Woche: ', $row['week'],'<br />';
echo 'Neue/Heute: ', $row['today'];
The result is that my forum don't wants to load :( Maybe something wrong with the 'else if ($context['user']['is_logged'] && !$context['user']['is_admin'])' ?
I think your else if statements need an else statement.
Not 100% sure, but I think any time you start and if statement with else if you have to finish with else.
if
else if
else if
else
Thanks for your answer!
But the problem still exists:
/*
1. Gaeste bekommen ForumStats angezeigt.
2. Mitglieder die Begruessungsbox
3. Admins die NeuRegistrierungen
#############################
by Tommy
#############################
*/
global $context,$db_prefix,$modSettings;
if ($context['user']['is_guest'])
TPortal_statsbox();
else if ($context['user']['is_logged'] && !$context['user']['is_admin'])
TPortal_userbox();
else
//if ($context['user']['is_admin'])
$today = strtotime("24 hours ago");
date('j') == 1 ? $thismonth = $today : $thismonth = strtotime(date('F') . ' 1');
date('l') == 'Sunday' ? $thisweek = $today : $thisweek = strtotime('last Sunday');
date('M') == 'January' ? $thisyear = $thismonth : $thisyear = strtotime('January 1');
$query = db_query("SELECT
COUNT(dateRegistered > $thisyear OR NULL) as year,
COUNT(dateRegistered > $thismonth OR NULL) as month,
COUNT(dateRegistered > $thisweek OR NULL) as week,
COUNT(dateRegistered > $today OR NULL) as today
FROM {$db_prefix}members
WHERE is_activated = 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);
settype($row['today'], "integer");
settype($row['week'], "integer");
settype($row['month'], "integer");
echo '<div style="text-align: center;"><span
style="font-weight: bold; text-decoration: underline;">Admin-Info</span></div>';
echo 'Mitglieder: ', $modSettings['totalMembers'],'<br />';
echo 'Neue/Monat: ', $row['month'],'<br />';
echo 'Neue/Woche: ', $row['week'],'<br />';
echo 'Neue/Heute: ', $row['today'];
Your last else statement is only executing this line:
$today = strtotime("24 hours ago");
If you want the rest of the code to execute you'll need to enclose the code with brackets.
else
{
all your other code here
}
Ooopsala - that's it! O0
Thank you IchBin !
Is there a way how I can add for example:
Female: 450
Male: 1200
I thougt to do it in:
'.$bullet. ' '.$modSettings['male']. '
'.$bullet. ' '.$modSettings['female']. '
The $bullet I wish to change to the male and female symbol (but where to do that ?) The text I have deleted becausse I have allreadye the male and female symbol. But where I have to find this
$modSettings['male']
or where I have to make it ? Or is there a other way ?
grtz,
deef
txks. alot this really worked for my site, but i have a problem, codes work only for center block, it dont work for left & right block. does anyone has code for left & right block?
Edited:- it works for right block
Nobody a idea how to do this ?
Greetings,
Deef
Quote from: deef on June 12, 2007, 11:19:12 AM
Is there a way how I can add for example:
Female: 450
Male: 1200
I thougt to do it in:
'.$bullet. ' '.$modSettings['male']. '
'.$bullet. ' '.$modSettings['female']. '
The $bullet I wish to change to the male and female symbol (but where to do that ?) The text I have deleted becausse I have allreadye the male and female symbol. But where I have to find this
$modSettings['male']
or where I have to make it ? Or is there a other way ?
grtz,
deef
Mine has a bit of a problem...
I had 8 people register today and it says 0, but the week and month are correct
it shows
New This Month: 164
New This Week: 19
New Today: 0
I dunno why it works with the other two and not that...Oh and I added it to a mini-user CP but I don't see how that could be the conflict
Check it out HERE (http://nextsite.org) it is the first block on the right and click stats
EDIT: NEVERMIND I FIXED IT
This is a great addition THANKS
Hi all
im having this error using the code in the first page :
Database Error
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '= 1' at line 1
File: C:\apache2\htdocs\smf\Sources\Load.php(1771) : eval()'d code
Line: 558
any help please ..
Please post the exact code you're using.
Hi JPDeni
im using this code below
global $db_prefix,$modSettings;
$today = strtotime("24 hours ago");
date('j') == 1 ? $thismonth = $today : $thismonth = strtotime(date('F') . ' 1');
date('l') == 'Sunday' ? $thisweek = $today : $thisweek = strtotime('last Sunday');
date('M') == 'January' ? $thisyear = $thismonth : $thisyear = strtotime('January 1');
$query = db_query("SELECT
COUNT(dateRegistered > $thisyear OR NULL) as year,
COUNT(dateRegistered > $thismonth OR NULL) as month,
COUNT(dateRegistered > $thisweek OR NULL) as week,
COUNT(dateRegistered > $today OR NULL) as today
FROM {$db_prefix}members
WHERE is_activated = 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($query);
settype($row['today'], "integer");
settype($row['week'], "integer");
settype($row['month'], "integer");
echo 'Total Members: ', $modSettings['totalMembers'],'<br />';
echo 'New This Month: ', $row['month'],'<br />';
echo 'New This Week: ', $row['week'],'<br />';
echo 'New Today: ', $row['today'];
I was just trying to figure out how you got to line 558 in that code. I guess with the queries it's different.
I don't know what could be wrong. It's been a very long time since I wrote that, so I don't remember anything about it. But it looks like it should work.
Try turning off that block to see if there's any errors. The only thing I can think of is that other code is interfering with the function.
i already removed this block, and as you said there was no error at all
other code ? you mean another block ? or mod ?
yes im tryin it in my testing forum which is full with other block and mod, ok ill try it first in other testing forum
it works in my other testing forum..thanks JPDeni
Quoteother code ? you mean another block ? or mod ?
Yes, that's what I was thinking. Or possibly your theme.
If it works in your testing forum, then there is definitely something else that's interfering.
i think it was the forum with all of the mod i used, in the new one i still used the same theme though ..
thanks again JPDeni :)