0
MySQL查詢和我使用得到符合特定標準的數據庫用戶PHP代碼:Mysql的陣列和數據
$sql = mysql_query("SELECT a2.id, a2.name FROM members a2 JOIN room f ON f.myid = a2.id
WHERE f.user = 1 AND a2.status ='7' UNION SELECT a2.id, a2.name FROM members a2
JOIN room f ON f.user = a2.id WHERE f.myid = 1 AND a2.status ='7' GROUP BY id")
or die(mysql_error());
while ($r = mysql_fetch_array($sql))
{
$temp[] = '"'.$r[0].'"';
}
$thelist = implode(",",$temp);
隨後通過使用獲得的新畫廊的成員名單查詢來自上一個查詢的數組。
$ft = mysql_query("SELECT id, pic1 FROM foto WHERE id IN ($thelist) AND
pic1!='' ORDER BY date DESC LIMIT 10");
while ($f = mysql_fetch_array($ft))
{
echo $f['id']." - ".$f['pic1']."<br/>";
}
這些查詢工作正常,但我需要爲第二個查詢中列出的每個用戶獲取名稱。這些數據位於列名的第一個查詢中。我怎樣才能讓它在'$ f ['id']旁邊列出。「 - 」。$ f ['pic1']'?