简体   繁体   English

如何从上次登录 3 天及更长时间获取行

[英]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.我基本上想编写一个 function 代码,它记录人们 3 天或更长时间未登录的地方,但它不起作用。

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.我基本上希望它达到 output 结果,它会显示 3 天或更长时间未登录的帐户。

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>";

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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