Umm, this could be written a lot shorter and faster...
PHP Code:
function loop_template($vars, $template, $subtemplate, $table, $conditions = '') {
global $DB_site;
$dblink = $DB_site->query("SELECT $vars FROM $table $conditions");
while ($db_array = $DB_site->fetch_array($dblink)) {
foreach ($db_array as $field => $value) { // DO NOT use while here
$array["{$subtemplate}_{$field}"] = $value;
unset($array["$field"]);
}
eval('$return .= "'.gettemplate($template.'_'.$subtemplate).'";');
}
$DB_site->free_result($dblink);
return $return;
}