我想回顯用戶表中的所有ID,但是我無法使其工作。我嘗試了下面的內容並搜索了一些堆棧,但我找不到正確的答案。從表中獲取所有的ID MYSQL
$query = $db->query("SELECT * FROM users");
$num = $db->num($query);
while($array = $db->assoc($query)) {
$active_ids = $array['id'];
}
$query = "SELECT u.username, u.habbo, count(*) AS n
FROM users u, timetable tt
WHERE u.id=tt.dj and u.id IN (".$active_ids.")
GROUP BY tt.dj";
$result = $mysqli->query($query);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()){
echo "<tr id='uren-table-row'>";
echo "<td width='60px'><div style='height:50px;padding-top:25px;overflow:hidden;float:left;margin-top:-25px;'><img style='margin-top:-28px;float:left;' src='http://habmoon.org/moonstream/dj?habbie={$row['habbo']}&head_direction=3&direction=2&size=b&hb=img&gesture=sml'></div></td>";
echo "<td width='200px' style='padding:0 15px;'>", $row['username'] ,"</td>";
echo "<td style='padding:0 15px;'>Heeft <b>", $row['n'] ,"</b> Uur gedraait deze week</td>";
echo "</tr>";
}
}
當您運行此代碼時會發生什麼? – nicomp
它只顯示1結果,但我需要回顯所有結果的@DelmerNicholson – Christian
執行'var_dump($ query)'。結果是什麼。 – Terminus