Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: May 2003
Posts: 94
Power User
Power User
Offline
Joined: May 2003
Posts: 94
Is there a command that would show me how many/which users have logged into the forum in a perscribed amount of time? I'd like to see how many 'unique' users visit us daily.

Sponsored Links
Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
This will show how many users have logged-in in the past day:

Code
 <br />SELECT count(*) <br />FROM w3t_Users <br />WHERE ( UNIX_TIMESTAMP() - U_Laston ) / ( 3600 * 24 ) <= '1' <br />


If you want to see information about who they were, you could do something like:

Code
 <br />SELECT U_Username <br />FROM w3t_Users <br />WHERE ( UNIX_TIMESTAMP() - U_Laston ) / ( 3600 * 24 ) <= '1' <br />

Joined: May 2003
Posts: 94
Power User
Power User
Offline
Joined: May 2003
Posts: 94
Works perfectly, THANKS!

Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
Go me! Go me!

Joined: May 2003
Posts: 94
Power User
Power User
Offline
Joined: May 2003
Posts: 94
Hmm ok upon further inspection, it seems to show users who've logged in during the last like 24 days, not 24 hours smirk Still good though! But I'd like to see how many in 24 hours

Sponsored Links
Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
SELECT U_Username FROM `w3t_Users`
WHERE `U_Laston` > (UNIX_TIMESTAMP( NOW() ) - 24 * 60 * 60)

Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
Returns the same thing, as both queries correctly pull the number of users that have logged-in in the past 24 hour - not days.

(UNIX_TIMESTAMP() - U_Laston ) / ( 3600 * 24 ) <= '1'

(Now - LastOn) = Seconds ago LastOn
Divide by (3600 * 24) (which is 86,400) since there are 3600 seconds in an hour, and 24 hours in 1 day.
If they were on exactly 24 hours ago (86,400 seconds) then the equation would thus simplify to 86,400/86,400 which equals "1" for 1 day.

Believe me - I use this equation for many features on my site, including "ranks" for users showing how long they've been registered, and I have yet to experience anything incorrect.

Joined: May 2003
Posts: 94
Power User
Power User
Offline
Joined: May 2003
Posts: 94
Ok, I understand your break down, however, that search returns 408 users out of 777. On close inspection of some of the names, I looked at 2, their 'last on' which resolves to April 14th and 18th.

We're running 6.5.1.1 and who knows the issues which are wrong, but honestly, the result don't show just 24 hours

Joined: Mar 2003
Posts: 159
Member
Member
Joined: Mar 2003
Posts: 159
OK, since we're on the subject, what would the query be to display those users that have not at least logged on the site within the last 6 month?

Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
Code
<br />SELECT U_Username<br />FROM w3t_Users<br />WHERE ( UNIX_TIMESTAMP() - U_Laston ) / ( 3600 * 24 ) >= '183'<br />

Sponsored Links
Joined: Mar 2003
Posts: 159
Member
Member
Joined: Mar 2003
Posts: 159
[]DLWebmaestro said:
Code
<br />SELECT U_Username<br />FROM w3t_Users<br />WHERE ( UNIX_TIMESTAMP() - U_Laston ) / ( 3600 * 24 ) >= '183'<br />
[/]
SQL 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 '(UNIX_TIMESTAMP() - U_Laston ) / ( 3600 * 24 ) > = '183'' at li
SQL Error #: 1064
Query: SELECT U_UsernameFROM w3t_UsersWHERE (UNIX_TIMESTAMP() - U_Laston ) / ( 3600 * 24 ) > = '183'

Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
Well that's what happens when you omit those spaces.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Gizmo
Gizmo
Portland, OR, USA
Posts: 5,833
Joined: January 2000
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)