I just asked a question earlier, but now i have formatted it into a function that does not return any value.
This is my code:
echo GetHours($UID, $DAY, $MONTH, $YEAR);
function GetHours($UserId, $Day, $Month, $Year){
//filter queries:
//YEAR:
if($Year==FALSE){
$Y = "";
} else {
$Y = " AND Year = '$Year'";
}
//MONTH:
if($Month==FALSE){
$M = "";
} else {
$M = " AND Month = '$Month'";
}
//DAY:
if($Day==FALSE){
$D = "";
} else {
$D = " AND Day = '$Day'";
}
$Query = mysql_query("SELECT SUM(TotalHrs)
FROM WorkLog
WHERE UserId = '$UserId'$D$M$Y");
$Data = mysql_fetch_array($Query);
return $Data;
}
Now, i do know that mysql_
functions are depreciated, but its required for this application at the moment.
My current problem is that this function does not return anything after using GET parameters to test.
Any solutions to this?
EDIT
I have changed the last lines to: return json_encode($Data);
and now the screen shows: {"0":"8","SUM(TotalHrs)":"8"}