If I put my code in a function it does not work. If I get rid of the function it is responding correctly. What I'm doing wrong?
function dayClosure() {
$qClosure = 'SELECT * FROM timeRegistration WHERE department IN ("4")';
$rClosure = mysqli_query($conn, $qClosure);
while($row = mysqli_fetch_assoc($rClosure)) {
if ($row['status'] == '3' && $row['enddate'] == '23-10-2017') {
$totalWorkedTime += $row['worktime'];
return $totalWorkedTime;
}
}
}
echo dayClosure();