我有這個奇怪的行爲,從我畫的表。當我添加超過7個條目到數據庫來繪製表格時,它好像崩潰了,並沒有畫任何東西。 7或更少,它工作得很好。陣列似乎停止後,7項
我不知道爲什麼它會這樣做?
$strSQL = "
SELECT u.username playername
, IFNULL(a.avatar,'default.jpg') playeravatar
FROM add_tournament_repeat_guests p
JOIN nfojm_users u
ON p.guestID = u.id
LEFT
JOIN nfojm_comprofiler a
ON u.id = a.user_id
WHERE p.parent_id = $tournID
";
$query = mysqli_query($con, $strSQL);
while ($row = mysqli_fetch_array($query)) {
if (!in_array($row["playername"], $playernames)) {
$i=0;
$indexes[$row["playername"]] = 0;
$playernames[] = $row["playername"];
} else {
$indexes[$row["playername"]]++;
$i = $indexes[$row["playername"]];
}
if (!in_array($row["playeravatar"], $playeravatars)) {
$i=0;
$indexes[$row["playeravatar"]] = 0;
$playeravatars[] = $row["playeravatar"];
} else {
$indexes[$row["playeravatar"]]++;
$i = $indexes[$row["playeravatar"]];
}
}
print('<table class="block" style="border:2px solid #999999; width:175px; background-color: aliceblue; margin-top:-7px"><thead><tr><th style="color:white; background-color:#444444; height:35px;"> <h2>Leaderboard</h2> </th></tr></thead><tbody>');
foreach (array_combine($playeravatars, $playernames) as $playeravatar => $playername) {
print("<tr><td style='padding-left:8px;' class='block'><h4><img src='http://www.arcadeicons.com/images/comprofiler/" . $playeravatar . "' height='35' width='35' style='border-radius:50%'> " . $playername . "</h4></td></tr>");
}
進一步的測試顯示它不是項目的數量,它獲得了超過一個虛擬形象的NULL結果。我怎麼能寫得更好,使2個或更多NULLS不打破數組? –
你可以在array_combine之前打印兩個數組$ $ playeravatars和$ playernames並將其添加到你的問題中?另外爲什麼兩個不同的數組,然後結合他們?你可以這樣做$ player [$ row [「playeravatar」]] = $ player [「playername」] – Hmmm