Hi, I have this but it does not work. I wish to add up all the rows but it does not add them. What am i doing wrong? $sql= mysql_query("SELECT * FROM `table` WHERE MONTH(date) = '$smonth'"); while ($row = mysql_fetch_assoc($sql)) { $total_hours = $row['hours']++; } $total = ($total_hours * 15); PHP: Cheers, Adam
$total_hours = $row['hours']++; Your code above keep re-assign a new value for $total_hours ( in fact, $total_hours + 1 ) You should make it as: $total_hours += $row['hours']; Basically the same as the post above.