Hey, guys, I need a little help.
This is a report in Wordpress that I need to modify. I need to take the data exemplified by the following table and insert it into a column in the report. (Just the last column.)
I’ve got a query that returns the following data (abbreviated):
SELECT week( time ) wknum, sll.uid UID, sll.user_login, count( sll.uid ) num_logins
FROM gga_simple_login_log sll
WHERE login_result = 1
GROUP BY wknum, sll.uid
ORDER BY wknum, sll.uid
LIMIT 20
wknum UID user_login num_logins
31 2017 David 1
32 4 ggray 2
32 9 customer 2
32 31 northwestteam 2
32 1147 35826 5
32 1179 39351 12
32 1620 92493 1
32 1738 0A1925 1
32 1928 0A7054 2
32 1930 Yael 2
32 1961 A036891 1
32 1997 0A7967 1
32 2017 David 2
33 4 ggray 3
33 9 customer 2
33 22 floridateam 1
33 27 southernteam 1
33 989 5848 2
33 1045 19333 1
33 1065 23425 2
The point of the above data is to show some conditions where the last column has non-zero / non-null values.
Here is an example where I’m grabbing exactly ONE week# and UID, which is closer to the actual use-case:
SELECT week( sll.time ) wknum, sll.uid UID, count( * ) NumLogins FROM gga_simple_login_log sll WHERE sll.login_result = 1 AND UID = 2017 AND week( sll.time ) = 32 LIMIT 0, 30 ;
wknum UID NumLogins
32 2017 2
That said, here’s the code I’m using in the plugin that’s supposed to grab the 3rd column from the above result (= 2):
$weeklyLoginsQuery = "SELECT count(sll.uid) as NumLogins FROM $wpdb->simple_login_log sll WHERE (sll.login_result=1) AND (week( sll.time ) = week(now())) AND (sll.uid = $theuser->ID )";
$weeklyLogins = $wpdb->get_row($weeklyLoginsQuery );
$user_data[] = '{ '. (empty($weeklyLogins) ? 'oops!' : $weeklyLogins[2]) .' }’;
This is running inside of a loop for the current week (which is 37 or 38 now) and it iterates over the UIDs and grags the NumLogins for that UID.
The problem is … no matter what I do, all I get is either NULL or empty in the result set. I don’t get any numeric data at all, for ANY of the UIDs.
Any idea what’s wrong? (I’ve tried a whole bunch of different things that all result in the same “nothing” output.
BTW, this is using the data in a table associated with a free WP Plugin named “Simple Login Log”.
I simply need a count of logins by UID for the current (or previous) week.
-David Schwartz
_______________________________________________
azPHP mailing list
azPHP@list.azphp.org
http://list.azphp.org/mailman/listinfo/azphp_list.azphp.org
---------------------------------------------------
PLUG-discuss mailing list -
PLUG-discuss@lists.phxlinux.org
To subscribe, unsubscribe, or to change your mail settings:
http://lists.phxlinux.org/mailman/listinfo/plug-discuss