<?php	

$thcols_rep = "";

$sqlmid = "select mid as mid_col,desc_rep,delta_col,delta_perc as delta_col_perc,expenses
			from ccmanager_id 
			where pid='".$pid."' order by 1";

$resultmid = mysqli_query($conn, $sqlmid);

if (mysqli_num_rows($resultmid) > 0) {
      while($rowmid = mysqli_fetch_assoc($resultmid)) {
		$mid_col		= $rowmid["mid_col"];
		$desc_rep		= $rowmid["desc_rep"];
		$delta_col_add	= $rowmid["delta_col"];
		$delta_col_perc	= $rowmid["delta_col_perc"];				
		$expenses_ev	= $rowmid["expenses"];				
		if ($delta_col_add == 0) 
			{
				$thcols_rep 	= $thcols_rep."<th style='text-align:center' >".$desc_rep."</td>";
			}
		if ($delta_col_add == 1) 
			{
						if ($delta_col_perc == 1) 
							{
								$thcols_rep 	= $thcols_rep."<th style='text-align:center' >".$desc_rep."</th><th style='text-align:center' >%</th>";
							}
						if ($delta_col_perc == 0) 
							{
								$thcols_rep 	= $thcols_rep."<th style='text-align:center' >".$desc_rep."</th>";
							}							
			}			
		if ($expenses_ev == 2) // EARNED VALUE CHECK
			{
					$thcols_rep 	= $thcols_rep."</th><th style='text-align:center' >".$desc_rep." %</th>";
			}			
    }
} 

echo $thcols_rep;

?>