<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hey, guys, I need a little help.<div class=""><br class=""></div><div class="">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.)<br class=""><div class=""><br class=""></div><div class="">I’ve got a query that returns the following data (abbreviated):</div><div class=""><br class=""></div><div class=""><font face="Courier New" class="">SELECT week( time ) wknum, sll.uid UID, sll.user_login, count( sll.uid ) num_logins<br class="">FROM gga_simple_login_log sll<br class="">WHERE login_result = 1<br class="">GROUP BY wknum, sll.uid<br class="">ORDER BY wknum, sll.uid</font></div><div class=""><font face="Courier New" class="">LIMIT 20</font></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><table id="table_results" class="data ajax" style="border: 0.1em solid rgb(0, 0, 0); border-collapse: collapse; border-spacing: 0px; font-family: Times; widows: 1; background-color: rgb(255, 255, 255);"><thead class=""><tr class=""><th class="draggable" data-column="wknum" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; background-color: rgb(229, 229, 229);">wknum</th><th class="draggable" data-column="UID" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; background-color: rgb(229, 229, 229);">UID</th><th class="draggable" data-column="user_login" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; background-color: rgb(229, 229, 229);">user_login</th><th class="draggable" data-column="num_logins" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; background-color: rgb(229, 229, 229);">num_logins</th><td style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;" class=""></td></tr></thead><tbody class=""><tr class="odd"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">31</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">2017</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">David</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">1</td></tr><tr class="even"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">32</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">4</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">ggray</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">2</td></tr><tr class="odd"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">32</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">9</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">customer</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">2</td></tr><tr class="even"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">32</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">31</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">northwestteam</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">2</td></tr><tr class="odd"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">32</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">1147</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">35826</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">5</td></tr><tr class="even"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">32</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">1179</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">39351</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">12</td></tr><tr class="odd"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">32</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">1620</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">92493</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">1</td></tr><tr class="even"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">32</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">1738</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">0A1925</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">1</td></tr><tr class="odd"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">32</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">1928</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">0A7054</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">2</td></tr><tr class="even"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">32</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">1930</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">Yael</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">2</td></tr><tr class="odd"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">32</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">1961</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">A036891</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">1</td></tr><tr class="even"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">32</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">1997</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">0A7967</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">1</td></tr><tr class="odd"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">32</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">2017</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">David</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">2</td></tr><tr class="even"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">33</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">4</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">ggray</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">3</td></tr><tr class="odd"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">33</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">9</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">customer</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">2</td></tr><tr class="even"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">33</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">22</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">floridateam</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">1</td></tr><tr class="odd"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">33</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">27</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">southernteam</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">1</td></tr><tr class="even"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">33</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">989</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">5848</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">2</td></tr><tr class="odd"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">33</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">1045</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">19333</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">1</td></tr><tr class="even"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">33</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">1065</td><td class=" data not_null" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;">23425</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">2<br class=""><br class=""></td></tr></tbody></table></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">The point of the above data is to show some conditions where the last column has non-zero / non-null values.</div><div class=""><br class=""></div><div class="">Here is an example where I’m grabbing exactly ONE week# and UID, which is closer to the actual use-case:</div><div class=""><br class=""></div><div class=""><font face="Courier New" class="">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 ;</font></div><div class=""><br class=""></div><div class=""><table id="table_results" class="data ajax" style="border: 0.1em solid rgb(0, 0, 0); border-collapse: collapse; border-spacing: 0px; font-family: Times; widows: 1; background-color: rgb(255, 255, 255);"><thead class=""><tr class=""><th class="draggable" data-column="wknum" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; background-color: rgb(229, 229, 229);">wknum</th><th class="draggable" data-column="UID" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; background-color: rgb(229, 229, 229);">UID</th><th class="draggable" data-column="NumLogins" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; background-color: rgb(229, 229, 229);">NumLogins</th><td style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em;" class=""></td></tr></thead><tbody class=""><tr class="odd"><td class=" data right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">32</td><td class=" condition data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">2017</td><td class=" data not_null right nowrap" style="border: 0.1em solid rgb(0, 0, 0); padding: 0.2em; white-space: nowrap;">2</td></tr></tbody></table><div class=""><br class=""></div></div><div class=""><br class=""></div><div class=""><div class="">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):</div><div class=""><br class=""></div><div class=""><font face="Courier New" class="">$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 )";<br class="">$weeklyLogins = $wpdb->get_row($weeklyLoginsQuery );<br class="">$user_data[] = '{ '. (empty($weeklyLogins) ? 'oops!' : $weeklyLogins[2]) .' }’;</font></div><div class=""><br class="">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.</div><div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">Any idea what’s wrong? (I’ve tried a whole bunch of different things that all result in the same “nothing” output.</div><div class=""><br class=""></div><div class="">BTW, this is using the data in a table associated with a free WP Plugin named “Simple Login Log”.</div><div class=""><br class=""></div><div class="">I simply need a count of logins by UID for the current (or previous) week.</div><div class=""><br class=""></div></div><div class=""><br class=""><div apple-content-edited="true" class="">-David Schwartz<br class=""><br class=""><br class=""></div><br class=""></div></div></div>_______________________________________________<br class="">azPHP mailing list<br class=""><a href="mailto:azPHP@list.azphp.org" class="">azPHP@list.azphp.org</a><br class="">http://list.azphp.org/mailman/listinfo/azphp_list.azphp.org<br class=""></body></html>