duanlei7101 2014-12-13 21:17
浏览 269

如果在一定时间后10分钟内

I'm trying to create a Users Online page for my site with just php. I have a table column called lastactive which is updated as a DATE/TIME (example: 2014-12-13 21:04:15) each time they visit a page.

Now I want my Users Online page to show all of the users who have been active within the last 10 minutes of the current time. So if it was 10pm, I'd want a users active from 9:50pm-10pm to show.

I found a previous StackOverflow question (can't find it now) that gave me some tips so I tried that and I ended up with this:

$timequery = mysqli_query($con,"SELECT times.lastactive FROM times WHERE lastactive >= NOW() - INTERVAL 10 MINUTE ORDER BY lastactive");

and

$whoisloggedin = mysqli_query($con,"SELECT username FROM users LEFT JOIN times ON times.id=users.id WHERE lastloggedin >= NOW() - INTERVAL 10 MINUTE ORDER BY lastloggedin");

But this just shows every user. Here's what I use to show the user

echo "Shows all active players from the last 10 minutes.";

while ($row = mysqli_fetch_assoc($timequery)) {
   $row2 = mysqli_fetch_array($whoisloggedin);
    $usersArray2 = $row2['username'];
    echo $usersArray2;
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题