Hello,
I'm after some help please.
In my login.php, a new entry is added into my logins table which consists of this structure:
CREATE TABLE `logins` (
`id_logins` int(11) NOT NULL auto_increment,
`dateadded` datetime NOT NULL default '0000-00-00 00:00:00',
`account` varchar(50) NOT NULL default '',
`ip_address` varchar(50) NOT NULL default '',
`reverse` varchar(250) NOT NULL default '',
PRIMARY KEY (`id_logins`)
) ENGINE=InnoDB AUTO_INCREMENT=441733 DEFAULT CHARSET=latin1 AUTO_INCREMENT=441733 ;
What I want to do is show all the accounts that have not logged in, so basically it should go through the table and select each distinct account and find its last login, and if that is over 2 weeks ago, list it.
I have used the following code, where the top part is finding the individual accounts fine. However, for my second part I'm not quite sure how to deal with it, can you help?
$login=mysql_query("Select DISTINCT account from logins order by account");
$num2=mysql_num_rows($login);
echo " <ul>\n";
if ($num2>0)
{
echo " <li>Unique <strong>logins</strong>: ";
$list = array();
while ($logins=mysql_fetch_array($login))
{
$list[] = "".$logins['account']."";
}
echo implode(', ', $list);
echo "</li>\n";
}
echo " </ul>\n";
$nologin=mysql_query("Select DISTINCT account from logins WHERE dateadded < now()-interval 2 week order by account");
$num3=mysql_num_rows($nologin);
echo " <ul>\n";
if ($num3>0)
{
echo " <li>No logins for <strong>2 weeks</strong> from: ";
$list = array();
while ($twow=mysql_fetch_array($twoweeks))
{
$list[] = "".$twow['account']."";
}
echo implode(', ', $list);
echo "</li>\n";
}
echo " </ul>\n";