我正在显示我的数据库中所有用户的列表,但是如果用户在线或离线,我想在每个用户名旁边显示一段时间。 现在它只在每个用户之后显示离线,而我自己在线。
$log = mysql_query("SELECT * FROM stage_users");
while($row = mysql_fetch_array($log))
{
echo '<tr>
<td class="qty"><a href="profiel.php?acc='.$row['Naam'].'">'.$row['Naam'].'</td>';
$upda = mysql_query("SELECT COUNT(*) FROM `stage_inloggen`
WHERE Seen > DATE_SUB(NOW(), INTERVAL 10 MINUTE)
AND `Gebruikersnaam` = '$name' LIMIT 1 ");
$num_rowst = mysql_fetch_array($upda);
$count = $num_rowst[0];
if($count!=0)
{
echo '<td class="stock in">Online</td>';
}
else
{
echo '<td class="stock out">Offline</td>';
}
}
答案 0 :(得分:2)
试试这个
$log = mysql_query("SELECT * FROM stage_users");
while($row = mysql_fetch_array($log))
{
$name = $row['Naam'];
echo '<tr>
<td class="qty"><a href="profiel.php?acc='.$name.'">'.$name.'</td>';
$upda = mysql_query("SELECT COUNT(*)
FROM `stage_inloggen` WHERE Seen > DATE_SUB(NOW(), INTERVAL 10 MINUTE)
AND `Gebruikersnaam` = '$name' LIMIT 1 ");
$num_rowst = mysql_fetch_array($upda);
$count = $num_rowst[0];
if($count!=0)
{
echo '<td class="stock in">Online</td>';
}
else
{
echo '<td class="stock out">Offline</td>';
}
}