<?php
function smarty_modifier_count_list_duration($id)
{
global $mysqli;
$sql = "SELECT SUM(media.duration) AS all_duration,lists_media.list_id,lists_media.media_id,media.id,media.duration FROM lists_media JOIN media ON lists_media.media_id=media.id WHERE lists_media.list_id='$id'";
$query = $mysqli->query($sql);
$check = $query->num_rows;
if ($check == 0) {
return 0;	
} else {
$row = $query->fetch_assoc();
return $row['all_duration'];
}
}
?>