How do I add two double numbers in PHP? I have two dates that I compare with each other and that works fine ($uren is the variable for that). But now I want to sum all those ($uren) from the while so I can make a week sum ($weekuren is the variable for that) from the separate hours ($uren). The problem is that it don't want to add. In the while are the hours ($uren) visible but they don't add. The numbers are double like 3.98 for example. What do I wrong?
$sq = mysql_query("SELECT * FROM presentielijst ORDER BY datum ASC") or die(mysql_error());
$tel = mysql_num_rows($sq);
echo "<table cellpadding='5' cellspacing='2' border='0' width='100%' style='font-size:14pt'>";
while($d = mysql_fetch_assoc($sq)) {
$p_id = stripslashes($d['p_id']);
$weeknummer = stripslashes($d['weeknummer']);
$dag = stripslashes($d['dag']);
$datum = stripslashes($d['datum']);
$weekuren = stripslashes($d['weekuren']);
$toelichting = stripslashes($d['toelichting']);
$kleur = stripslashes($d['kleur']);
$aanmeldtijd = strtotime($d['aanmeldtijd']);
$afmeldtijd = strtotime($d['afmeldtijd']);
$uren = abs($afmeldtijd - $aanmeldtijd) / 3600; //row value 1: 6.17 //row value 2: 3.980
$uren = round($uren, 2);
$weekuren = $uren += $uren;
echo "<td class='presentieurentd' width='380px' bgcolor='".$kleur."' onclick=open_gegevens('".$p_id."')>".$uren."</td>";
}
echo $weekuren; //value 7.96? Strange value based on I don't know
echo "</table>";
Thanks in advance Edit: the values I want to add are 6.1666666667 + 3.983611111
$weekuren = $uren * 2;
$weekuren += $uren;
?mysql_fetch_assoc()
you’re using a seriously outdated version of PHP or a polyfill that was intended to be a temporary stopgap until you migrate your code. That function no longer exists.