Ik denk dat de fout zit met de functie SUM die ik ik gebruik, alleen ik kan niet vinden wat.
Mijn code:
<?php
$conn = mysql_connect("$host", "$user", "$pass");
if (!$conn) {
echo "Kan geen verbinding maken met de DB: " . mysql_error();
exit;
}
if (!mysql_select_db("$db")) {
echo "Kan mydbname niet selecteren: ";
}
$sql = "SELECT naam, sum(1comp) AS totaal, 1comp, sum(2comp) AS totaal2, 2comp, sum(beker) AS totaal3, beker, sum(oefen) AS totaal4, oefen
FROM topscorers
GROUP BY naam";
$result = mysql_query($sql);
if (!$result) {
echo "Kon de query ($sql) niet uitvoeren: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "Geen rijen gevonden, niets te printen, dus stoppen.";
exit;
}
while ($row = mysql_fetch_assoc($result)) {
$echo1 = $row['totaal'];
?>
<TD width=140 bgColor=#ffffff height=20><font size="1" face="Verdana"><?php echo "". $row['naam']; ?></font></TD>
<TD align=middle width=31 height=20><font size="1" face="Verdana"><?php echo "". $row['1comp']; ?></font></TD>
<TD align=middle width=38 height=20><font size="1" face="Verdana"><?php echo "". $row['2comp']; ?></font></TD>
<TD align=middle width=55 height=20><font size="1" face="Verdana"><?php echo "". $row['beker']; ?></font></TD>
<TD align=middle width=60 height=20><font size="1" face="Verdana"><?php echo "". $row['oefen']; ?></font></TD>
<TD align=middle width=80 height=20><B><font size="1" face="Verdana">34</font></B></TD></TR>
<?php
}
?>
<TR>
<TD width=140 bgColor=#ffffff height=20></TD>
<TD align=middle width=69 colSpan=2 height=20></TD>
<TD align=middle width=55 height=20></TD>
<TD align=middle width=60 height=20></TD>
<TD align=middle width=80 height=20></TD></TR>
<TR>
<TD width=140 bgColor=#ffb400 height=20><font size="1" face="Verdana">Totaal</font></TD>
<TD align=middle width=31 bgColor=#ffb400 height=20><font size="1" face="Verdana"><?php echo $echo1 ?></font></TD>
<TD align=middle width=38 bgColor=#ffb400 height=20><font size="1" face="Verdana"><?php echo "". $row['totaal2']; ?></font></TD>
<TD align=middle width=55 bgColor=#ffb400 height=20><font size="1" face="Verdana"><?php echo "". $row['totaal3']; ?></font></TD>
<TD align=middle width=60 bgColor=#ffb400 height=20><font size="1" face="Verdana"><?php echo "". $row['totaal4']; ?></font></TD>
<TD align=middle width=80 bgColor=#ffb400
height=20><B><font size="1" face="Verdana">122</font></B></TD></TR></TBODY></TABLE><font size="1" face="Verdana"><BR></font>
</p>
<?php
mysql_free_result($result);
?> Ik heb al gedaan:
-Veel getest
-Op forums gekijken wat over de functie SUM ging.
Ik hoop dat iemand mijn kan helpen