我有這個表:MySQL和PHP關聯數組
Username, Fan, Count
1danny22, katana1973, 2
bob, rita, 2
mattyhacky, hayley, 2
mattyhacky, dickie1eye, 1
mattyhacky, xxjodiexx, 1
而且我希望將其加載到一個關聯數組,這將是這樣的:
Array (
[1danny22] => Array (
[katana1973] => 2,
),
[bob] => Array (
[rita] => 2,
),
[mattyhacky] => Array (
[hayley] => 2,
[dickie1eye] => 1,
[xxjodiexx] = > 1,
)
)
$strSQL = "SELECT username, fan, count(*) AS intCount FROM fan GROUP BY username, fan ORDER BY username, intCount DESC"; $strResult = mysql_query($strSQL); while($objRow=mysql_fetch_object($strResult)) { code should go in here!!! }
但我真的很掙扎。
有人可以幫忙嗎?
非常感謝
TheBounder。
掙扎着什麼?你試過什麼了? –