Here is my function:
function timePerMonth($query, $ecid, $pos)
{
include "../connection.php";
$sql = sprintf("SELECT `TOTAL` FROM jos_onlinetime_$pos WHERE CID='%s' && `MONTH`='$query'",
mysql_real_escape_string($ecid, $con));
$query = mysql_query($sql, $con) or die("There was an error with the query: $sql" . mysql_error());
$total = "0";
if(mysql_num_rows($query) != "0")
{
while ($mtotal = mysql_fetch_assoc($query))
{
$total = $total + $mtotal['TOTAL'];
}
$dtotal = timeCalc($total, "Y");
}
if(mysql_num_rows($query) == "0")
{
$dtotal = "00:00";
}
return $dtotal;
}
Here is the TimeCalc Function:
function timeCalc($seconds, $month)
{
$hour = floor($seconds / 3600);
$min = floor(($seconds % 3600) / 60);
if($month == "Y")
{
$time = $hour . ":" . $min;
}else{
$time = $hour . " hours and " . $min . " minutes";
}
return $time;
}
Its not outputting anything. But I'm not getting an error either lol. Any ideas?