Yeah they both are INT type, I believe they are unsigned. So this is what I should have:
PHP Code:
function getResponseTime()
{
global $db, $vbulletin, $hour, $minute;
$result = $db->query_read("SELECT * FROM `" . TABLE_PREFIX . "pl9_support_tickets` ORDER BY tid DESC LIMIT 30");
$ticket_num = $db->num_rows($result);
if($ticket_num > 0)
{
$i = 0;
$seconds = 0;
while ($res = $db->fetch_array($result)){
$query = $db->query_first("SELECT radded FROM `" . TABLE_PREFIX . "pl9_support_replies` WHERE ticket='". $res['tid'] ."' ORDER BY radded ASC LIMIT 1");
$query_num = $db->num_rows($query);
$rep = $query['radded'];
$tick = $res['tadded'];
$seconds += ($rep - $tick);
$i++;
}
if($i>0)
{
$avg = $seconds / $i;
}
} else {
$avg = 0;
}
$hour = floor($avg/3600);
$resttime = $avg - ($hour*3600);
$minute = floor($resttime/60);
return;
}
So is that what it should look like? If so I will test it right quick.
--------------- Added [DATE]1265060826[/DATE] at [TIME]1265060826[/TIME] ---------------
Ok I tested the code, result was the following:
Both my fields are INT type UNSIGNED.