<?php
include "scrinit.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<style type="text/css">
table.o { border-collapse:collapse;border:solid 2px #00F ;}
table.o td {border:solid 2px #00F; padding:2px ; word-wrap:break-word;} 
table.o th { border:2px solid black; background-color: #CCF;padding:2px;font-size:10pt;word-wrap:break-word; }
<p style="font-size:10px;"></p>
</style>
<body>

<?php
require "dbconnect.php";
$dt=date('Y-m-d');
   
 
//..............................
$ep1=$ep2=$ep3=$ep4=array();
$sql=mysqli_query($con,"SELECT * FROM epitropes order by code" );
$pere=array();

while ($row = mysqli_fetch_array($sql))
	{
		
		$cc[$row['code']]=$row['code'];
		$pere[$row['code']]=$row['perigrafi'];
		
	}

$coun=$ep=array();
$sql = mysqli_query($con,"SELECT t.Name,d.* FROM teachers as t,dilosiep as d WHERE d.teach=t.PMP  " );
$c=mysqli_num_rows($sql);
$i=1;
while ($row = mysqli_fetch_array($sql))
{	
		$n[$i]=$row['Name'];
		$ep[$i][1]=$row['code1'];
		$ep[$i][2]=$row['code2'];
		$ep[$i][3]=$row['code3'];
		$ep[$i][4]=$row['code4'];
	$i++;
}

$xls_filename = 'export_'.date('Y-m-d').'.xls'; // Define Excel (.xls) file name

//create a file and send to browser for user to download
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=$xls_filename");
header("Pragma: no-cache");
header("Expires: 0"); 
 
// Start of printing column names as names of MySQL fields
$header= "A/A". ","."ΕΚΠΑΙΔΕΥΤΙΚΟΣ". ","."ΕΠΙΤΡΟΠΗ1".","."ΕΠΙΤΡΟΠΗ2". ","."ΕΠΙΤΡΟΠΗ3".","."ΕΠΙΤΡΟΠΗ4";
print "$header\n";
 
// Start while loop to get data
for ($i=1;$i<=$c;$i++)
{
	$data = $i.",".$n[$i].",".$pere[$ep[$i][1]].",".$pere[$ep[$i][2]].",".$pere[$ep[$i][3]].",".$pere[$ep[$i][4]];
$data = trim( $data ) . "\n";
$data = str_replace( "\r" , "" , $data );
print "$data";
} 


?>
<br /><br />
<a  href=<?php echo $menu;?> style="color:blue "  > <button> Επιστροφή στο Μενού  </a>
</body>
</html>