Du har en navngivningsfejl ved anden variabel "secondnumber".
$number = 0;
$query = mysql_query("SELECT * FROM tal where") or die(mysql_error());
while($row = mysql_fetch_array( $query )) {
$firstnumber = $row['firstnumber'];
$secondnumber = $row['secondnumber'];
$number += ($firstnumber+$secondnumber);
}
eller
$number = array();
$query = mysql_query("SELECT * FROM tal where") or die(mysql_error());
while($row = mysql_fetch_array( $query )) {
$firstnumber = $row['firstnumber'];
$secondnumber = $row['secondnumber'];
$number[] = ($firstnumber+$secondnumber);
}
$number = array_sum($number);
Indlæg senest redigeret d. 07.12.2011 10:39 af Bruger #10216