好的,我的代码有点问题:它没有得到第一个结果? 例如:禁令表可能如下所示: [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&advSearch=" . $steamid110 . "&advType=steamid&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个结果。
答案 0 :(得分:2)
因为您在调用您使用的真实提取之前不必要地调用了一个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))
答案 1 :(得分:-1)
查询($ sql44)是不应该在连接之前出现(我想在mysqli_query中有$ GLOBALS [“___ mysqli_ston”])?