我有这个表: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。
挣扎着什么?你试过什么了? –