我设法制作一个完全正常的记分牌,但它有一个小问题。我总是将我的“地点”数字增加1.如果两个竞争者的结果相同,他们应该有相同的“地点”。
目前我的代码(只有PHP我在表中回应它):
<?php
while( $row = mysql_fetch_assoc( $u10z ) ){
print "<tr>";
print "<td>" . $i1 . "</td>";
print "<td>" . $row['ime'] . "</td>";
print "<td>" . $row['priimek'] . "</td>";
print "<td>" . $row['klub'] . "</td>";
print "<td>" . $row['drzava'] . "</td>";
print "<td>" . $row['vrh'] . "</td>";
print "<td>" . $row['vrhPoskus'] . "</td>";
print "<td>" . $row['bonus'] . "</td>";
print "<td>" . $row['bonusPoskus'] . "</td>";
print "</tr>";
$i1++;
}
?>
正如您所见,$i1
是一个“地点”计数器。
如果你看第二张桌子,first(1)
和second(2)
竞争对手都应该在first(1)
位置,因为它们都有相同的分数。
eighth(8)
和ninth(9)
竞争者也应该在eighth(8)
位置。
修改
我现在正在使用下面评论的代码,但我有一点问题。数字被转移了。
<?php
$pre_vrh = false;
$pre_vrhPoskus = false;
$pre_bonus = false;
$pre_bonusPoskus = false;
while( $row = mysql_fetch_assoc( $u10z ) ){
print "<tr>";
print "<td>" . $i1 . "</td>";
print "<td>" . $row['ime'] . "</td>";
print "<td>" . $row['priimek'] . "</td>";
print "<td>" . $row['klub'] . "</td>";
print "<td>" . $row['drzava'] . "</td>";
print "<td>" . $row['vrh'] . "</td>";
print "<td>" . $row['vrhPoskus'] . "</td>";
print "<td>" . $row['bonus'] . "</td>";
print "<td>" . $row['bonusPoskus'] . "</td>";
print "</tr>";
if ($pre_vrh != $row['vrh'] || $pre_vrhPoskus != $row['vrhPoskus'] || $pre_bonus != $row['bonus'] || $pre_bonusPoskus != $row['bonusPoskus']) {
$i1++;
}
$pre_vrh = $row['vrh'];
$pre_vrhPoskus = $row['vrhPoskus'];
$pre_bonus = $row['bonus'];
$pre_bonusPoskus = $row['bonusPoskus'];
}
?>
图像: New results
答案 0 :(得分:0)
在谈论得分时,我无法理解你的意思,但......看起来如果$row['vrh'], $row['vrhPoskus'], $row['bonus'], $row['bonusPoskus']
是相同的,那么地方必须是相同的。如果代码可以像这样,那就是真的
<?php
$pre_vrh = false;
$pre_vrhPoskus = false;
$pre_bonus = false;
$pre_bonusPoskus = false;
$place = 1;
$i1 = 0;
while( $row = mysql_fetch_assoc( $u10z ) ){
print "<tr>";
// we should compare old and new values for getting place
if ($pre_vrh != $row['vrh'] || $pre_vrhPoskus != $row['vrhPoskus'] || $pre_bonus != $row['bonus'] || $pre_bonusPoskus != $row['bonusPoskus']) {
$place = $i1 + 1;
}
$i1++;
print "<td>" . $place . "</td>";
print "<td>" . $row['ime'] . "</td>";
print "<td>" . $row['priimek'] . "</td>";
print "<td>" . $row['klub'] . "</td>";
print "<td>" . $row['drzava'] . "</td>";
print "<td>" . $row['vrh'] . "</td>";
print "<td>" . $row['vrhPoskus'] . "</td>";
print "<td>" . $row['bonus'] . "</td>";
print "<td>" . $row['bonusPoskus'] . "</td>";
print "</tr>";
$pre_vrh = $row['vrh'];
$pre_vrhPoskus = $row['vrhPoskus'];
$pre_bonus = $row['bonus'];
$pre_bonusPoskus = $row['bonusPoskus'];
}
?>