I am created a sign in history for my control panel, and I am having small problem with the way it is to
displaying the results.
My db select is:
$securelogs = DBSelectAllArrays("SELECT login_date, ip_address, failed FROM ".SECURITY_LOG_TABLE." ".
"WHERE login_id = '".addslashes($USER['client_id'])."' ".
"ORDER BY login_date DESC");
I am trying to display to different results from select statement above. My 2nd is working just fine and
displays the results I require, the first on the other hand is off and is what I need help with.
First Result: (it is to display the 2nd last correct login)
foreach ($securelogs as $stop=>$securelog)
{
if ($stop == '1')
{
print "<tr valign=\"top\"><td class=\"medfont\">Last Login:</td>\n";
print "<td class=\"medfont\">".$securelog['ip_address']."/".gethostbyaddr($securelog['ip_address'])."</td></tr>\n";
print "<tr valign=\"top\"><td> </td><td class=\"medgray\">".sprintf('Your account was last accessed on %s at %s', date("F dS Y", CnvTime ($securelog['login_date'])), date("g:m a", CnvTime ($securelog['login_date'])))."</td></tr>\n";
}
}
Example:
If there are several correct logins and the last 2 are Feb. 15, and Feb. 17 it is to display Feb. 15.
As it is now above, the results are displaying the 2nd last one, but if the 2nd last one was a failed result it display it instead, which isn't want I want.
It needs to grab the 2nd last correct login. Should I be grouping my sql select, or can I fix it in the foreach function above?
Second Result: (displays all the failed logins)
foreach ($securelogs as $securelog)
{
if (!empty($securelog['failed']))
{
print date("M. d Y", CnvTime ($securelog['login_date']))."\n";
}
}