top10 system fungerer ikke korrekt
Dette script fungerer ikke korrekt.Den sorterer således:
1. pladsen: Titel: test2
Antal stemmer: 2
Score: 3
2. pladsen: Titel: test3
Antal stemmer: 2
Score: 2.5
3. pladsen: Titel: test1
Antal stemmer: 1
Score: 5
Har denne kode:
<?
if($_GET[go] == 'top10') {
$id = 1;
$query = mysql_query('SELECT picid, SUM(vote) AS samlet FROM pic_votes GROUP BY picid ORDER BY samlet DESC LIMIT 0,10') or die(mysql_error());
while($row = mysql_fetch_array($query)) {
$query2 = mysql_query("SELECT picid FROM pic_votes WHERE picid = '$row[picid]'") or die(mysql_error());
$ialt2 = mysql_num_rows($query2);
$picurl_info = mysql_query("SELECT pic_url, titel FROM pics WHERE id = '$row[picid]'") or die(mysql_error());
$picurl = mysql_fetch_array($picurl_info);
if($ialt2 != '0') {
$score = $row[samlet] / $ialt2;
} else {
$score = '0';
}
echo"<b>$id",". pladsen:</b><table width=\"370\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" height=\"71\">
<tr>
<td width=\"70\" valign=\"top\"><IMG SRC=\"pictures/$picurl[pic_url]\" ALT=\"\" height=\"71\" width=\"70\"></td>
<td width=\"300\" valign=\"top\">Titel: $picurl[titel]<br>
Antal stemmer: $ialt2<br>
Score: $score<br><br>
</td>
</tr>
</table><br><br>";
$id++;
}
}
?>
