I use this basic code to do something similar to what you are looking for.
PHP Code:
<?php
$OneWeekAgo = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d")-7, date("Y")));
$query = DatabaseQuery("SELECT * FROM table");
while($rows = mysql_fetch_array($query)){
if ($rows[lastaction] < $OneWeekAgo)
echo $rows[name].' last action was more than one week ago ('.$rows[lastaction].')<br>'."\n";
else
echo $rows[name].' was active <b>within the last week</b> ('.$rows[lastaction].')<br>'."\n";
}
?>
Change the table and field names to suit your needs.
** DatabaseQuery(); is a self made database access function, so you will have to alter the query to suit your needs, but the rest is straightforward.