0

好的,我的代码有一点问题:它没有得到第一个结果?例如:禁止表可能如下所示:[http://i.stack.imgur.com/dYuCd.png][1] 但回显的数据将错过第一行,原因为 RDMx3 和 Evade ,并且没有名字。

例如:这里直接来自 SourceBans:http: //i.stack.imgur.com/Snxzv.png

这是使用以下代码的版本:http: //i.stack.imgur.com/eCexb.png

请注意,显示在第一张图像上的第一个禁令不会显示在第二张图像上。(不要介意第二张图片的长度,我必须解决这个问题。)

<?php
$sql44 = "SELECT * FROM `sb_bans` ORDER BY `created` DESC LIMIT 6";
$res44 = mysqli_query($GLOBALS["___mysqli_ston"], $sql44) or trigger_error(((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
$row44 = mysqli_fetch_assoc($res44);

while($row44 = mysqli_fetch_array($res44))
{
$sid1 = $row44['sid'];
$name1 = $row44['name'];
$steamid110 = $row44['authid'];
$reason1 = $row44['reason'];
$timesec = $row44['length'];
$unbanstatus = $row44['RemoveType'];

if($unbanstatus == "U")
{
$type1 = "(U)";
}
elseif($unbanstatus == "E")
{
$type1 = "(E)";
}
else
{
$type1 = "";
}
if($sid = 1)
{
$serv = "<img src='http://bans.versound.net/images/games/gmodttt.png' alt='TTT' />";
}
elseif($sid = 2)
{
$serv = "TF2 AU";
}
elseif($sid = 3)
{
$serv = "SB AU";
}
else
{
$serv = "wtf";
}
if($name1 == NULL)
{
$name1 = "no nickname present";
}
else
{
$name1 = $name1;
}
if($timesec == "0")
{
$length1 = "Permanent";
}
else
{
$length2 = gmdate("d", $timesec);
$length1 = "$length2 days";
}
echo "<tr style='" . $type2 . "'>\n<td style='text-align:center'>" . $serv . "</td>\n<td><a href='http://bans.versound.net/index.php?p=banlist&amp;advSearch=" . $steamid110 . "&amp;advType=steamid&amp;Submit' target='_blank'>" . $name1 . "</a></td>\n<td>" . $reason1 . "</td>\n<td>" . $length1 . " " . $type1 . "</td>\n</tr>\n";
}
?>

为什么会出现这种情况?你能帮助我吗?另外,我使用 DESC LIMIT 6 因为 DESC LIMIT 5 错过了第一个结果,并且只输出 4 个结果。

4

2 回答 2

2

因为您在fetch调用您使用的真正 fetch 之前不必要地调用了一个并浪费了它。

$row44 = mysqli_fetch_assoc($res44);  //This line is not needed and should go

while($row44 = mysqli_fetch_array($res44))

应该只是

while($row44 = mysqli_fetch_array($res44))
于 2013-05-20T07:13:22.210 回答
-1

在 mysqli_query 中,查询($sql44)不应该在连接(我想 $GLOBALS["___mysqli_ston"]) 之前先出现吗?

于 2013-05-20T07:23:47.203 回答