简体   繁体   中英

How do I get rows from 3 days last login and longer

I'm trying to code a feature for my service that I have and I'm sort of struggling to get it to work..

I basically want to code a function where it logs where people haven't logged in for 3 or more days, but it just won't work.

I currently have:

$findActivity = mysqli_query($conn, "SELECT * FROM users WHERE 'last_active' < CURRENT_TIMESTAMP - 3 DAY");
while($activeRow = mysqli_fetch_assoc($findActivity)){
    
    $usr = $activeRow['username'];;
    $la = $activeRow['last_active'];

    echo "<tr class='row100 body'>";
    echo "<td class='cell100 column3'>$usr</td>";
    echo "<td class='cell100 column3'>$inactivefor</td>";
    echo "<td class='cell100 column3'>$msg</td>";
    echo "</tr>";
}

I basically want it to output results where it will display accounts that have not logged in for 3 or more days.

Try this:

$findActivity = mysqli_query($conn, "SELECT * FROM users WHERE last_active < 
CURRENT_TIMESTAMP - INTERVAL 3 DAY");
while ($activeRow = mysqli_fetch_assoc($findActivity)) {
$usr = $activeRow['username'];
$la = $activeRow['last_active'];

echo "<tr class='row100 body'>";
echo "<td class='cell100 column3'>$usr</td>";
echo "<td class='cell100 column3'>$la</td>";
echo "</tr>";

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM