Hallo!
Ich hab vor einiger Zeit eine Highscore-Liste erstellt. Anfangs war die Ausgabe vollkommen richtig, aber mittlerweile haben sich fehlerhafte Einträge eingeschlichen!
Hier die Highscore-Liste
Wie man sieht, ist z.b. ein User drei mal mit gleicher Punktzahl vorhanden, ein anderer wiederum zweimal mit komplett unterschiedlichen punkten.
Mein Code:
DB auslesen:
PHP-Code:
$sql = "SELECT user_id, first_places, second_places, third_places
FROM phpbb_ina_user_data
WHERE first_places != 0 OR second_places != 0 OR third_places != 0
ORDER BY (first_places*3)+(second_places*2)+third_places DESC
LIMIT 50";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain regd user/online information', '', __LINE__, __FILE__, $sql);
}
Ausgabe:
PHP-Code:
<?php
$place = 0;
while ($row = $db->sql_fetchrow($result))
{
$place++;
$sql3 = "SELECT username
FROM phpbb_users
WHERE user_id = ". $row['user_id'];
if ( !($result3 = $db->sql_query($sql3)) )
{
message_die(GENERAL_ERROR, 'Could not obtain regd user/online information', '', __LINE__, __FILE__, $sql3);
}
$row3 = $db->sql_fetchrow($result3);
$points = ($row['first_places']*3)+($row['second_places']*2)+$row['third_places'];
echo "<tr><td width='20' align='center' bgcolor='#9fc49d' style='padding: 2px;'>".
$place
."</td>
<td width='210' bgcolor='#bad4b7' style='padding: 2px;'>
<a href='http://".$row3['username'].".180bpm.com' target='_blank'>".$row3['username']."</a>
</td>
<td width='40' align='center' bgcolor='#9fc49d' style='padding: 2px;'>".
$row['first_places']
."</td>
<td width='40' align='center' bgcolor='#bad4b7' style='padding: 2px;'>".
$row['second_places']
."</td>
<td width='40' align='center' bgcolor='#9fc49d' style='padding: 2px;'>".
$row['third_places']
."</td>
<td width='50' align='center' bgcolor='#bad4b7' style='padding: 2px;'>".
$points
."</td></tr>";
}
?>
Danke, Bogi