Firstly you state a variable that matches your columns [inside the parenthesis e.g (DNI)] and give the command to calculate their average. Finally name the average e.g 'adni'.
$avg_names=array('1'=>'AVG(DNI) as adni', '2'=>'AVG(GHI) as aghi', '3'=>'AVG(Zenith_Angle) as azenith', '4'=>'AVG(DiffuseHI) as adhi');
$average="SELECT ".implode(",", $avg_names)." FROM $database_Database_Test.$table_name where DATE>=\"$fromdate\" AND DATE<=\"$todate\"";