I'm trying to write a feature for my service, but I'm having some difficulty getting it to work.
Basically, I want to write a function that logs users who haven't logged in for more than 3 days, but it just doesn't work.
My current code is as follows:
$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 those accounts that have not been logged in for more than 3 days.
P粉2695300532023-09-15 12:27:17
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>";
}