query($querystatement); if($queryresult) { if($db->numRows($queryresult)){ $therecord=$db->fetchArray($queryresult); if(hasRights($therecord["roleid"])){ header("Content-type: ".$therecord["type"]); header("Content-Disposition: attachment; filename=\"".rawurlencode($therecord["name"])."\""); echo $therecord["file"]; } } } } ?>